These two buttons; one is enabled and the one with the style is disabled. Can anyone figure out why?
<Button Command="{Binding ResolveHostsCommand}" VerticalAlignment="Center" IsEnabled="{Binding CanUserUpdateHosts}" Grid.Column="0" Content="Resolve" />
<Button VerticalAlignment="Center" IsEnabled="False" Content="Cancel" Grid.Column="1">
<Button.Style>
<Style TargetType="Button">
<Style.Triggers>
<DataTrigger Binding="{Binding CanUserUpdateHosts}" Value="True">
<Setter Property="IsEnabled" Value="True"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Button.Style>
</Button>
Even if you set CanUserUpdateHosts to true, the Style.Setter cannot override the explicit value you provided in the Button declaration. See the Dependency Property Value Precedence page. Style setters in triggers are at #6, while the explicit value is #3.
You would need to reverse your logic, like so:
Or you could set the IsEnabled to false using a Setter of your Style, like so: