'What is wrong with the binding I have set?

I have a Xamarin Forms custom control that includes the following in code behind:

public static readonly BindableProperty LastNameProperty = BindableProperty.Create(
    propertyName: nameof(LastName),
    returnType: typeof(string),
    declaringType: typeof(ProfileLayout),
    defaultValue: string.Empty,
    defaultBindingMode: BindingMode.TwoWay
);

public string LastName
{
    get => (string)GetValue(LastNameProperty );
    set => SetValue(LastNameProperty , value);
}

And this is in the xaml:

<Label Text="{Binding LastName, Source={x:Reference thisControl}}">

Then, in the view model of the class that uses this control, there is this:

private string _nameValue;
public string NameValue
{ 
    get => _nameValue; 
    set
    {
        _nameValue = value;
        OnPropertyChanged();
    }
}

And the xaml implementing the custom control is:

<baseView:ProfileLayout LastName="{Binding NameValue}"/>

I have tried various combinations of binding modes for LastNameProperty and in both xaml bindngs, but I the Label text does not change when I change NameValue.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source