I have a StackPanel
(1), with another StackPanel
(2) inside.
SP 2 should be hidden (Opacity:0) until SP 1 is hovered. The mouse-over should change the style of SP2 to Opacity:100.
I've tried defining styles in the StackPanel resources, and using triggers there to then target the inside panel, but I'm not sure how I should be targeting the children from inside the trigger.
What would be a simple style structure to do this?
I do not fully understand what you need so i posted 2 samples.
Sample with colors for clarity :
1) when we have mouseover on sp1 sp2 getting green color
<Window x:Class="Prognoz.GP.DataCollection.TestMarkupProject.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" >
<Window.Resources>
<Style x:Key="test" TargetType="StackPanel">
<Setter Property="Background" Value="Red" />
<Style.Triggers>
<DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=StackPanel,AncestorLevel=1}, Path=IsMouseOver}" Value="True" >
<Setter Property="Background" Value="Green" />
</DataTrigger>
</Style.Triggers>
</Style>
</Window.Resources>
<Grid>
<StackPanel Width="400" Height="400" Background="Yellow">
<StackPanel Width="350" Height="350" Style="{StaticResource test}"/>
</StackPanel>
</Grid>
</Window>
2) when we have mouseover on sp2 sp2 getting green color
<Style x:Key="test" TargetType="StackPanel">
<Setter Property="Background" Value="Red" />
<Style.Triggers>
<Trigger Property="StackPanel.IsMouseOver" Value="True" >
<Setter Property="Background" Value="Green" />
</Trigger>
</Style.Triggers>
</Style>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With