So, I have a grid inside a listbox. The purpose is that when the listboxitem is selected, I want the grid to show, having the selected item expand to show more detail information. I set up a style trigger for this and it works great, except for one thing: the labels and textblocks styles are unapplied on the grid.
I'm assuming this has something to do with the default state of the listboxitem being collapsed, so wpf skips the styles, I was hoping it would put them on when selected fired, but it doesn't. If I use Style="{StaticResource Mystyle}" on each label/textblock, it styles fine, it just seems to not be doing the inherited style magic like it does with visible grids elsewhere in the app. See code below, the labels don't show up bolded or anything when the grid appears.
<Style TargetType="{x:Type Grid}" x:Key="ListBoxItemCollapseGrid">
<Style.Triggers>
<DataTrigger Binding="{Binding
Path=IsSelected,
RelativeSource=
{
RelativeSource
Mode=FindAncestor,
AncestorType={x:Type ListBoxItem}
}
}"
Value="False">
<Setter Property="Grid.Visibility" Value="Collapsed" />
</DataTrigger>
</Style.Triggers>
<Style.Resources>
<Style TargetType="{x:Type Label}">
<Setter Property="FontWeight" Value="Bold" />
<Setter Property="Foreground" Value="{StaticResource BaseText}" />
<Setter Property="Padding" Value="3,0,0,0" />
</Style>
<Style TargetType="{x:Type TextBlock}">
<Setter Property="Foreground" Value="{StaticResource BaseText}" />
</Style>
</Style.Resources>
</Style>