I have stack panel containing three textblocks bounded with different member variable.I
want to set a property on textblocks foreground based on Is mouse over property. can i use
the same is mouse over property for all textblocks of the panel or i have to set for each
and every textblock? This is the first time i’m using triggers.
Here is my code
<StackPanel Grid.ColumnSpan="3" HorizontalAlignment="Left" Orientation="Horizontal" Margin="0,-3,0,2.932">
<TextBlock Grid.Column="0" Text="{Binding Path=Location}" Foreground="#FFFFF1A5" Style="{StaticResource Textstyle}" />
<TextBlock Grid.Column="1" Text="{Binding Path=Name}" Foreground="#FFFFF1A5" Style="{StaticResource Textstyle}" />
<TextBlock Grid.Column="2" Text="{Binding Path=Age}"Foreground="#FFFFF1A5" Style="{StaticResource Textstyle}" />
<StackPanel.Resources>
<Style x:Key="Textstyle" TargetType="{x:Type TextBlock}">
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Foreground" Value="#FFFFFFFF"/>
</Trigger>
</Style.Triggers>
</Style>
</StackPanel.Resources>
</StackPanel>
Is there anything wrong in my approach?
Because im not getting any result from this.Please answer my question.please
Your local Foreground property is overriding the Style. Set the default Foreground property in the style instead.