wpf-mvvmアプリケーションにボタンコントロールがあります。
プロパティ(viewmodelで定義)を使用してICommand
、ボタンクリックイベントをviewmodelにバインドします。
->実行と実装canexecute
用のパラメーターがありますICommand
(RelayCommand
)。
偽の場合でもCanExecute
...ボタンが無効になっていない...ボタンの内容が画像の場合
ただし、ボタンの内容がテキストの場合、有効化/無効化は正常に機能します。
<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>