There are several GroupBox controls in my window, each of which contains Grid Control. For those grids I want to style. But only for those grids that are located directly in GroupBox, all other grids should not be affected.
I tried the following, which does not work, since GetType () is not a property.
<Style TargetType="Grid"> <Style.Triggers> <DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=Self}, Path=Parent.GetType()}" Value="{x:Type GroupBox}"> </DataTrigger> </Style.Triggers> </Style>
I found a workaround, but this is not a very pretty solution, since I need to change GroupBoxes:
<Style TargetType="GroupBox"> <Setter Property="Tag" Value="blub"/> </Style> <Style TargetType="Grid"> <Style.Triggers> <DataTrigger Binding="{Binding Path=Parent.Tag, RelativeSource={RelativeSource Mode=Self}}" Value="blub"> </DataTrigger> </Style.Triggers> </Style>
Obviously, I could set the style for each Grid manually, but I try to avoid this, as there are so many of them. I hope you can find a way to do the first work example.
PeterE
source share