-2

Recently, TargetNullValue support has been added to XF, but the description is different from the description in WPF. Is this just a mistake in the description, but they work in the same way?

WPF

Gets or sets the value that is used in the target when the value of the source is null.

Xamarin.Forms

Gets or sets the value to supply for a bound property when the target of the binding is null.

If they work identically, then the description of operation in WPF is more precise and reflects the sense of operation, while the description in XF introduces confusion.

g_m
  • 456
  • 1
  • 3
  • 12

1 Answers1

1

Ok, I checked it and in XF it works in the same way as in WPF. This means that in XF, the description is simply incorrect.

TargetNullValue

<Label BindingContext="{Binding Employee}" Text="{Binding Path=Name, TargetNullValue='Hello'}" />

Source (with null)

public class Employee : INotifyPropertyChanged
{
    private string _name = null;
    public string Name
    {
        get => _name;
        set
        {
            if (value != _name)
            {
                _name = value;
                Raise();
            }
        }
    }

    public event PropertyChangedEventHandler PropertyChanged;
    private void Raise([CallerMemberName] string name = "")
    {
        PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
    }
}

The word "Hello" appears in Label.Text

g_m
  • 456
  • 1
  • 3
  • 12