I working on a XAML style for my controls. The code below is for setting the color of a stackpanel. It works fine but there is something else I want to do. If the trigger is activated I want to set the font color for all child items inside the stackpanel.
At the moment I only have textblocks inside the stackpanel and I know I could easily create a separate style for a textbock. But if this style is triggered it will only affect ONE and not ALL textblocks. But I want to change all items inside the stackpanel as soon as I got a mouseover trigger for the panel.
Is this even possible in XAML or do I have to code a regular event?
<Style x:Key='XStack' TargetType='StackPanel'> <Setter Property='Background'> <Setter.Value> <LinearGradientBrush StartPoint='0,0' EndPoint='0,1'> <GradientStop Color='White' Offset='0'/> <GradientStop Color='SkyBlue' Offset='6'/> </LinearGradientBrush> </Setter.Value> </Setter> <!-- Trigger--> <Style.Triggers> <Trigger Property='IsMouseOver' Value='True' > <Setter Property='Background' Value='SkyBlue'/> </Trigger> </Style.Triggers> </Style>
Add this to your trigger:
<Setter Property='TextElement.Foreground' Value='Blue'></Setter>