我对最新版本的isVisible的绑定有问题.Net毛伊岛预览版17.3.0预览版2.0.可能与版本无关.我没有使用MVVM..这是我的代码:
<Frame Background="LightBlue" IsVisible="{Binding FrameVisible}" x:Name="Frame_Test" Margin="0,10,0,0" CornerRadius="25" HeightRequest="100">
在XAML的后端,我有一个要绑定到的布尔值
private bool frameVisible;
public bool FrameVisible
{
get
{
return frameVisible;
}
set
{
frameVisible = value;
OnPropertyChanged("FrameVisible");
}
}
我正在实施InotifyPropertyChanged
public event PropertyChangedEventHandler PropertyChanged;
private void OnPropertyChanged(string propertyName)
{
Console.WriteLine($"[App] Property changed {propertyName}");
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
在我的类构造函数中,我将bindingcontext设置为this;