我在当前代码中面临一个问题。
UI 有一个按钮,该按钮数据绑定到依赖属性 showbutton。它建立在 MVVM 架构之上。
XAML 看起来像这样。
<Grid>
.........
<Button .... IsEnabled="{Binding Path=class1.class2.showbutton,RelativeSource={RelativeSource FindAncestor, AncestorType=views:view2, Mode=FindAncestor, AncestorLevel=1}}"/>
...... <\网格>
注册的依赖属性看起来像这样
public static readonly DependencyProperty buttonDisplay= DependencyProperty.Register("showbutton", typeof(bool), typeof(class2), new PropertyMetadata((bool)false));
public bool showbutton
{
get { return (bool)GetValue(buttonDisplay); }
set { SetValue(buttonDisplay, value); }
}
更新被称为直通
private void UpdateProperties()
{
showbutton= User.CheckPrivilege("ShudEnable"); }
}
该按钮未根据 showbutton 启用。可能是什么问题?是否可以以编程方式更改 showbutton 值。如果有怎么办?