I have a button which is bound to a filtered DataView (always 1 record):
<Button x:Name="btnValidate" Grid.Row="0" Grid.RowSpan="2" Grid.Column="3" Cursor="Hand" Click="btnValidate_Click">
<Button.Style>
<Style TargetType="{x:Type Button}">
<Setter Property="Background" Value="{StaticResource ValidationNoneBrush}" />
<Setter Property="Tag" Value="{Binding VALIDATED, Converter={StaticResource DebugConverter}}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<Border x:Name="bdrValidate" Background="{TemplateBinding Background}">
<Image Source="../Images/24/LocationSearch.png" Stretch="None" />
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="Tag" Value="1">
<Setter Property="Background" Value="Blue"/>
</Trigger>
</Style.Triggers>
</Style>
</Button.Style>
</Button>
As you can see, I have a converter set for debugging, and it’s working fine. The values I see passing through the converter are 0’s and 1’s. So why is the background not changing based on the Style Trigger? I can’t figure it out …
Presumably your converter is returning the integer 0 or integer 1? The
Tagproperty is of typeObject, so the XAML compiler assumes the “1” value in your trigger is astring, not anintEither change your converter to return a
string, or specify anintvalue in your trigger: