RIck Mueller

RIck Mueller

  • NA
  • 47
  • 0

Collapse Expanders in list box

May 14 2010 10:02 AM

I Want to to be able to click a expander and if any other expanders are open would close. I was able to get it to work. But when I Data bind the expanders, it doesn't work.
 
 

 <Style x:Key="ContainerStyle1" TargetType="{x:Type GroupItem}">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate>
     <StackPanel>
                     <Expander IsExpanded="{Binding IsSelected, Mode=OneWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ListBoxItem}}}"
                      x:Name="Xp11"
                      Style="{DynamicResource ExpanderStyle1}"
                      Margin="0,3,0,3"
                      Foreground="White"
                      FontSize="20" 
                      Width="255" 
                      BorderBrush="White" >
       <Expander.Header>
       <StackPanel VerticalAlignment="Center" HorizontalAlignment="Center">
       <TextBlock Foreground="White" FontSize="7"  Text="{Binding ItemCount}"/>
       <TextBlock Foreground="White" Text="{Binding Name}"/>
       </StackPanel>
       </Expander.Header>
                      <Expander.Background>
                       <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                        <GradientStop Color="#FFABA8A8" Offset="0.337"/>
                        <GradientStop Color="#3A0A0A0A" Offset="0.609"/>
                       </LinearGradientBrush>
                      </Expander.Background>
 
                      <ItemsPresenter/>
                     </Expander>
     </StackPanel>
                    </ControlTemplate>
     
                </Setter.Value>
            </Setter>
    <Style.Triggers>
                <Trigger Property="Content" Value="{x:Null}"/>
            </Style.Triggers>
        </Style>

 
 
 
Any thoughts?
 
 
Regards,
Rick

Answers (2)