我的 wpf-mvvm 应用程序中有一个按钮控件。
我使用一个ICommand
属性(在 viewmodel 中定义)将按钮单击事件绑定到 viewmodel。
我的实现有 -> 执行和canexecute
参数ICommand
(RelayCommand
)。
即使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>