I have an usercontrol with a
`LlistBox`, which has an
`ItemsSource` with a Collectionview. In order to group, I used the group style where the grouped items will be within the `Expander` control as follows.
I want the `Exapander` with the
label content "UNKNOWN" has to be Closed by default and rest of them should remain opened, so i have tried two methods , but none of them worked,
Quote:
1. Using Data Trigger Within Controltemplate.Triggers
2. Using Data Trigger Within Controltemplate.Resources
Since the number of Expander counts varies based on the group ,Is it possible to open and close the Expander using ShortCut keys??
for eg:If i have two Expander(Animals/Birds),using
Alt+F1i need to close or open " Exapnder Animals"
using
Alt+F2 i need to close or open " Exapnder Birds"
<GroupStyle.ContainerStyle>
<Style TargetType="{x:Type GroupItem}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type GroupItem}">
<ControlTemplate.Triggers>
<DataTrigger Binding="{Binding ElementName=lbl, Path=Content}" Value="UNKNOWN">
<Setter Property="Expander.IsExpanded" Value="False" />
</DataTrigger>
</ControlTemplate.Triggers>
<ControlTemplate.Resources>
<Style TargetType="{x:Type Expander}">
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=lbl, Path=Content}" Value="UNKNOWN">
<Setter Property="Expander.IsExpanded" Value="False" />
</DataTrigger>
</Style.Triggers>
</Style>
</ControlTemplate.Resources>
<Expander IsExpanded="True" FlowDirection="LeftToRight" >
<Expander.Header >
<Label x:Name="lbl" BorderBrush="Black" BorderThickness="0.5"
Content="{Binding Path = Name}" Width="{Binding ElementName=MyList, Path=ActualWidth}"
FontSize="16" FontFamily="Verdana"/>
</Expander.Header>
<Expander.Content>
<ItemsPresenter />
</Expander.Content>
</Expander>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</GroupStyle.ContainerStyle>