Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Binding to label #18

Open
420tech opened this issue Aug 21, 2023 · 1 comment
Open

Binding to label #18

420tech opened this issue Aug 21, 2023 · 1 comment

Comments

@420tech
Copy link

420tech commented Aug 21, 2023

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:

<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.

@tranb3r
Copy link

tranb3r commented Dec 14, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants