我试图隐藏基于bool的元素。我在这个例子中使用了一个按钮,但无论我使用什么元素类型,它都不起作用。
这是包含绑定的XAMl。
<Button
Command="local:CustomCommands.Toggle"
Content="Toggle"
Visibility="{Binding Show, Converter={StaticResource BoolToVis}}" />
这是我绑定的视图模型。
public class MyModel : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
private bool show = true;
public bool Show
{
get
{
return show;
}
set
{
value = show;
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(nameof(Show)));
}
}
}
}
我已经调试并查看了属性更改,但未对视图进行更新。
有什么想法吗?