我的WPF App中有MenuItem:
<MenuItem Header="_Login" Click="Login_Click" Name="mi_Login">
如何动态绑定本地bool var上的IsEnabled属性:
public bool _IsConnected
{
get { return this.IsConnected; }
set { this.IsConnected = value; }
}
答案 0 :(得分:1)
不要忘记在主容器上设置DataContext:
<Window DataContext="{Binding Path=YourViewModelOrCodeBehindOtherwise}">
<MenuItem Header="_Login" Click="Login_Click" Name="mi_Login"
IsEnabled="{Binding _IsConnected}" >
</Window>