I have a TextBlock and two path objects (Up arrow & Down arrow) in a Stack Panel. The TextBlock is bound to a Property called 'Change', which possibly can have values such as -1,0,1.
Problem I wanted to show Up arrow in case of 1 OR Down arrow in case of -1 OR show neither of these Path object in case of 0.
In order to achieve this, I defined a Style Trigger on Path type.
Question
I am not able to get it work. Am i missing something or is there better way of doing this.
XAML
<StackPanel Orientation="Horizontal">
<TextBlock Name="changeLbl" Margin="0,0,10,0" Text="{Binding Path=Change}"/>
<Path Fill="{Binding ElementName=changeLbl,Path=Foreground}" Style="{StaticResource downChangePathTrigger}"/>
<Path Fill="{Binding ElementName=changeLbl,Path=Foreground}" Style="{StaticResource upChangePathTrigger}"/>
</StackPanel>
Style resource
<Style x:Key="upChangePathTrigger" TargetType="Path">
<Setter Property="Visibility" Value="Collapsed" />
<Setter Property="HorizontalAlignment" Value="Center" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Data" Value="M 0 4 L 4 0 L 8 4 Z" />
<Setter Property="StrokeThickness" Value="5" />
<Setter Property="Stroke" Value="GreenYellow"/>
<Style.Triggers>
<Trigger Property="Fill" Value="GreenYellow">
<Setter Property="Visibility" Value="Visible"/>
</Trigger>
</Style.Triggers>
</Style>
<Style x:Key="downChangePathTrigger" TargetType="Path">
<Setter Property="Visibility" Value="Collapsed" />
<Setter Property="HorizontalAlignment" Value="Center" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Data" Value="M 0 0 L 4 4 L 8 0 Z" />
<Setter Property="StrokeThickness" Value="5" />
<Setter Property="Stroke" Value="Red"/>
<Style.Triggers>
<Trigger Property="Fill" Value="Red">
<Setter Property="Visibility" Value="Visible"/>
</Trigger>
</Style.Triggers>
</Style>
Update with answer
Style trigger
<Style x:Key="changePathTrigger" TargetType="Path">
<Setter Property="Visibility" Value="Hidden" />
<Setter Property="HorizontalAlignment" Value="Center" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="StrokeThickness" Value="5" />
<Style.Triggers>
<!--<DataTrigger Binding="{Binding Path=Change,Converter={StaticResource doubleToIntConverter}}" Value="0">
<Setter Property="Stroke" Value="0"/>
</DataTrigger>-->
<DataTrigger Binding="{Binding Path=Change,Converter={StaticResource doubleToIntConverter}}" Value="1">
<Setter Property="Visibility" Value="Visible"/>
<Setter Property="Data" Value="M 0 4 L 4 0 L 8 4 Z"/>
</DataTrigger>
<DataTrigger Binding="{Binding Path=Change,Converter={StaticResource doubleToIntConverter}}" Value="-1">
<Setter Property="Visibility" Value="Visible"/>
<Setter Property="Data" Value="M 0 0 L 4 4 L 8 0 Z"/>
</DataTrigger>
</Style.Triggers>
</Style>
Xaml
<Path Fill="{Binding ElementName=changeLbl,Path=Foreground}" Stroke="{Binding ElementName=changeLbl,Path=Foreground}" Style="{StaticResource changePathTrigger}"/>