Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: WPF shortcut Templates Keyboard , +
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>
Posted 5-Jul-13 22:37pm

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Maciej Los 315
1 OriginalGriff 273
2 Aajmot Sk 224
3 Marcin Kozub 210
4 Richard MacCutchan 200
0 OriginalGriff 7,853
1 Sergey Alexandrovich Kryukov 7,107
2 DamithSL 5,604
3 Manas Bhardwaj 4,986
4 Maciej Los 4,790


Advertise | Privacy | Mobile
Web03 | 2.8.1411023.1 | Last Updated 6 Jul 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100