I have a Command bound to a Button in XAML. When executed, the command changes a property value on the underlying DataContext. I would like the button's Content to reflect the new value of the property.
This works*:
<Button Command="{x:Static Member=local:MyCommands.TestCommand}"
Content="{Binding Path=TestProperty, Mode=OneWay}" />
But this doesn't:
<Button Command="{x:Static Member=local:MyCommands.TestCommand}">
<Button.Style>
<Style TargetType="{x:Type Button}">
<Style.Triggers>
<DataTrigger Binding="{Binding Path=TestProperty, Mode=OneWay}" Value="True">
<DataTrigger.Setters>
<Setter Property="Content" Value="Yes"/>
</DataTrigger.Setters>
</DataTrigger>
<DataTrigger Binding="{Binding Path=TestProperty, Mode=OneWay}" Value="False">
<DataTrigger.Setters>
<Setter Property="Content" Value="No"/>
</DataTrigger.Setters>
</DataTrigger>
</Style.Triggers>
</Style>
</Button.Style>
</Button>
Why is that?
*
By "works" I mean the Content gets updated whenever I click the button. I don't know if it's important or not, but just in case it is, I'm using .NET 3.5 SP1.
UPDATE:
I also tried another variation (removing the second DataTrigger in favor of default value), still to no avail:
<Button Command="{x:Static Member=local:MyCommands.TestCommand}">
<Button.Style>
<Style TargetType="{x:Type Button}">
<Setter Property="Content" Value="No"/>
<Style.Triggers>
<DataTrigger Binding="{Binding Path=TestProperty, Mode=OneWay}" Value="True">
<DataTrigger.Setters>
<Setter Property="Content" Value="Yes"/>
</DataTrigger.Setters>
</DataTrigger>
</Style.Triggers>
</Style>
</Button.Style>
</Button>
TIA