maui-bindableproperty-generator icon indicating copy to clipboard operation
maui-bindableproperty-generator copied to clipboard

Binding to label

Open 420tech opened this issue 1 year ago • 1 comments

I am not sure what I am doing wrong here - I am trying to bind the text value of a label as part of my custom control.

My control code behind looks like this: using Maui.BindableProperty.Generator.Core; namespace TestCustomControls.Controls;

public partial class HeaderControl : VerticalStackLayout { [AutoBindable()] private readonly string? _firstName;

[AutoBindable(DefaultBindingMode = nameof(BindingMode.OneWayToSource))]
private readonly string? _message;

public HeaderControl()
{
    InitializeComponent();
}

}

My control xaml looks like this:

<VerticalStackLayout x:Class="TestCustomControls.Controls.HeaderControl" xmlns="http://schemas.microsoft.com/dotnet/2021/maui" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml">

<Label Text="First Name" />
<Entry Text="{Binding Source={x:Reference this}, Path=FirstName}" />
<Label
    FontAttributes="Bold"
    FontSize="Header"
    Text="{Binding Source={x:Reference this}, Path=Message}"
    TextColor="Black" />

My test solution can be found at https://github.com/420tech/TestCustomControls. I can't get the label to render.

420tech avatar Aug 21 '23 15:08 420tech

I think the bindingmodes are wrong: FirstName should be OneWayToSource and Message should be OneWay.

tranb3r avatar Dec 14 '23 09:12 tranb3r