最近,已将TargetNullValue支持添加到XF,但是其描述与WPF中的描述不同。这只是描述中的错误,但是它们以相同的方式工作吗?
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.
如果它们工作相同,则WPF中的操作描述会更加精确并反映操作感,而XF中的描述会引起混淆。
答案 0 :(得分:1)
好吧,我检查了一下,在XF中它的工作方式与WPF中相同。这意味着在XF中,描述完全不正确。
TargetNullValue
<Label BindingContext="{Binding Employee}" Text="{Binding Path=Name, TargetNullValue='Hello'}" />
来源(为空)
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));
}
}
“ Hello”一词出现在Label.Text中