【发布时间】:2023-03-16 04:20:02
【问题描述】:
我的 wpf-mvvm 应用程序中有一个按钮控件。
我使用ICommand 属性(在视图模型中定义)将按钮点击事件绑定到视图模型。
我的 ICommand 实现 (RelayCommand) 有 -> 执行和 canexecute 参数。
即使CanExecute 为假...按钮未被禁用...当按钮内容为图像时
但是,当按钮内容是 text..enable/disable 工作正常。
<Button DockPanel.Dock="Top"
Command="{Binding Path=MoveUpCommand}">
<Button.Content>
<Image Source="/Resources/MoveUpArrow.png"></Image>
</Button.Content>
<Style>
<Style.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Opacity" Value=".5" />
</Trigger>
</Style.Triggers>
</Style>
</Button>
【问题讨论】:
标签: wpf mvvm icommand canexecute