4
나는 어떤 속성에 따라 실행 가능하거나 불가능할 수있는 간단한 버튼이있는 ItemTemplate를 가지고있다.바운드 명령 canexecute에 따라 단추 배경색을 변경하는 방법?
명령을 실행할 수없는 경우이 단추의 배경색을 변경하고 싶습니다. 여러 가지 방법을 시도했지만 어쨌든이 작업을 XAML에서만 수행 할 수는 없습니다 (학습 컨텍스트에서이 작업을하고 있으며 코드 숨김이 허용되지 않습니다).
<Button x:Name="Dispo" HorizontalAlignment="Center" Margin="0" VerticalAlignment="Center" Width="30" Height="30"
Grid.Column="2" Grid.Row="0"
Command="{Binding AddEmpruntCommandModel.Command}"
CommandParameter="{Binding ElementName='flowCars', Path='SelectedItem'}"
vm:CreateCommandBinding.Command="{Binding AddEmpruntCommandModel}" >
<Button.Style>
<Style TargetType="{x:Type Button}">
<Style.Triggers>
<Trigger Property="IsEnabled" Value="True">
<Setter Property="Button.Background" Value="Green"/>
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Button.Background" Value="Red"/>
</Trigger>
</Style.Triggers>
</Style>
</Button.Style>
</Button>