2016-07-25 14 views
0

Entschuldigung für den irreführenden Titel. Jedenfalls werde ich versuchen, es besser zu erklären. Ich möchte die Sammlung in Sammlungen in einem ListView anzeigen. Aber die Anzeige sollte Expander verwenden, um innere Sammlungselemente anzuzeigen. Alle Elemente sollten in den entsprechenden Spalten angezeigt werden. Eigentlich, was ich tat, ist dies:Sammlung der Gruppenbeschreibung aus einer Liste als Quelle anzeigen

XAML

<CollectionViewSource x:Key="GroupedItems" Source="{Binding Countries}"> 
<CollectionViewSource.GroupDescriptions> 
    <PropertyGroupDescription PropertyName="Name"/> 
</CollectionViewSource.GroupDescriptions> 
</CollectionViewSource> 
... 
<ListView ItemsSource="{Binding Source={StaticResource GroupedItems}}" Name="Playing"> 
    <ListView.View> 
     <GridView> 
      <GridViewColumn Header="Country" Width="150" DisplayMemberBinding="{Binding Source={x:Static sys:String.Empty}}" /> 
      <GridViewColumn Header="Leagues">       
       <GridViewColumn.CellTemplate> 
        <DataTemplate> 
         <ItemsControl ItemsSource="{Binding Leagues}" Margin="25 0 0 0"> 
          <ItemsControl.ItemTemplate> 
           <DataTemplate> 
            <Grid HorizontalAlignment="Stretch" Background="#FFBCDAEC"> 
             <TextBlock FontSize="18" Padding="5" Text="{Binding Name}"/> 
            </Grid> 
           </DataTemplate> 
          </ItemsControl.ItemTemplate> 
         </ItemsControl> 
        </DataTemplate> 
       </GridViewColumn.CellTemplate> 
      </GridViewColumn> 
     </GridView> 
    </ListView.View> 
    <ListView.GroupStyle> 
     <GroupStyle> 
      <GroupStyle.ContainerStyle> 
       <Style TargetType="{x:Type GroupItem}"> 
        <Setter Property="Template"> 
         <Setter.Value> 
          <ControlTemplate> 
           <Expander IsExpanded="True"> 
            <Expander.Header> 
             <TextBlock Text="{Binding Name}" Foreground="Red" FontSize="22" VerticalAlignment="Bottom" /> 
            </Expander.Header> 
            <ItemsPresenter /> 
           </Expander> 
          </ControlTemplate> 
         </Setter.Value> 
        </Setter> 
       </Style> 
      </GroupStyle.ContainerStyle> 
     </GroupStyle> 
    </ListView.GroupStyle> 
</ListView> 

Der obige Code zeigt im Expander der Name des Landes, aber leider kann ich nicht als Liste der Expander zeigen, verwalten die Länder nennen, sind innerhalb einer Liste.

Ich möchte Expander für Ligen zu zeigen und entsprechende Übereinstimmungen sollten in der entsprechenden Spalte erscheinen. In meinem ViewModel habe ich eine Sammlung von Ländern und jede Country>Leagues collection >Matches Sammlung.

Siehe die Klassen unter:

public partial class WinExpander : Window 
{ 
    public WinExpander() 
    { 
     InitializeComponent(); 

     this.DataContext = new ViewModel(); 
    } 
} 

public class ViewModel 
{ 
    public List<Country> Countries { get; set; } 
    public ViewModel() 
    { 
     Countries = new List<Country>(); 
    } 
} 

public class Country 
{ 
    public string Name { get; set; } 
    public List<League> Leagues { get; set; } 

    public Country() 
    { 
     Leagues = new List<League>(); 
    } 
} 

public class League 
{ 
    public string Name { get; set; } 
    public List<Match> Matches { get; set; } 

    public League() 
    { 
     Matches = new List<Match>(); 
    } 
} 

public class Match 
{ 
    public string Name { get; set; } 
} 

Antwort

0

Output

  1. Verwenden Expander für Matches. Um Matches synchron mit Leagues anzuzeigen, synchronisieren Sie sowohl den Expander Leagues als auch den Expander Matches. Wenn wir einen League erweitern, wird der entsprechende Expander ebenfalls erweitert.

  2. Für das richtige Aussehen und Gefühl, müssen wir die Expander Icon von Match Spalte entfernen.

  3. synchronisieren League und MatchExpanders, eine Eigenschaft einzuführen namens 'IsExpanded' in League. Jetzt League Klasse muss INotifyPropertyChanged implementieren.

    bool _isExpanded=true; 
    public bool IsExpanded 
    { 
        get { return _isExpanded; } 
        set { _isExpanded = value; OnPropertyChanged("IsExpanded"); } 
    } 
    

Listview-Markup:

<ListView ItemsSource="{Binding Source={StaticResource GroupedItems}}" Name="Playing"> 
    <ListView.View> 
     <GridView> 
      <GridViewColumn Header="Country" Width="150" DisplayMemberBinding="{Binding Source={x:Static sys:String.Empty}}" /> 
      <GridViewColumn Header="Leagues"> 
       <GridViewColumn.CellTemplate> 
          <DataTemplate> 
           <ItemsControl Margin="25 0 0 0" ItemsSource="{Binding Leagues}"> 
            <ItemsControl.ItemTemplate> 
             <DataTemplate> 
              <Expander IsExpanded="{Binding IsExpanded, Mode=TwoWay}" Margin="5" > 
               <Expander.Header> 
                <TextBlock FontSize="18" Padding="5" Text="{Binding Name}"/> 
               </Expander.Header> 
               <ItemsControl ItemsSource="{Binding Matches}"> 
                <ItemsControl.ItemTemplate> 
                 <DataTemplate> 
                  <TextBlock FontSize="18" Padding="5" Text="{Binding Source={x:Static sys:String.Empty}}"/> 
                 </DataTemplate> 
                </ItemsControl.ItemTemplate> 
               </ItemsControl> 
              </Expander> 
             </DataTemplate> 
            </ItemsControl.ItemTemplate> 
           </ItemsControl> 
          </DataTemplate> 
         </GridViewColumn.CellTemplate> 
      </GridViewColumn> 
      <GridViewColumn Header="Match"> 
       <GridViewColumn.CellTemplate> 
          <DataTemplate> 
           <ItemsControl Margin="25 0 0 0" ItemsSource="{Binding Leagues}"> 
            <ItemsControl.ItemTemplate> 
             <DataTemplate> 
              <Expander Style="{StaticResource MatchExpanderStyle}" IsExpanded="{Binding IsExpanded, Mode=TwoWay}" Margin="5">             
               <Expander.Header> 
                <TextBlock Visibility="Hidden" FontSize="18" Padding="5" Text="{Binding Name}"/> 
               </Expander.Header> 
               <ItemsControl ItemsSource="{Binding Matches}"> 
                <ItemsControl.ItemTemplate> 
                 <DataTemplate> 
                  <TextBlock FontSize="18" Padding="5" Text="{Binding Name}"/> 
                 </DataTemplate> 
                </ItemsControl.ItemTemplate> 
               </ItemsControl> 
              </Expander> 
             </DataTemplate> 
            </ItemsControl.ItemTemplate> 
           </ItemsControl> 
          </DataTemplate> 

         </GridViewColumn.CellTemplate> 
      </GridViewColumn> 
     </GridView> 
    </ListView.View> 
    <ListView.GroupStyle> 
     ... 
    </ListView.GroupStyle> 
</ListView> 

Setzen Sie diese ganze Sache unter Window.Resources oder Application.Resources. Ich habe die Visibility zu versteckt in ToggleButton mit dem Namen HeaderSite geändert. Alles wird automatisch von VS generiert.

<SolidColorBrush x:Key="Expander.MouseOver.Circle.Stroke" Color="#FF3C7FB1"/> 
      <SolidColorBrush x:Key="Expander.MouseOver.Circle.Fill" Color="Transparent"/> 
      <SolidColorBrush x:Key="Expander.MouseOver.Arrow.Stroke" Color="#222"/> 
      <SolidColorBrush x:Key="Expander.Pressed.Circle.Stroke" Color="#FF526C7B"/> 
      <SolidColorBrush x:Key="Expander.Pressed.Circle.Fill" Color="Transparent"/> 
      <SolidColorBrush x:Key="Expander.Pressed.Arrow.Stroke" Color="#FF003366"/> 
      <SolidColorBrush x:Key="Expander.Disabled.Circle.Stroke" Color="DarkGray"/> 
      <SolidColorBrush x:Key="Expander.Disabled.Circle.Fill" Color="Transparent"/> 
      <SolidColorBrush x:Key="Expander.Disabled.Arrow.Stroke" Color="#666"/> 
      <SolidColorBrush x:Key="Expander.Static.Circle.Fill" Color="Transparent"/> 
      <SolidColorBrush x:Key="Expander.Static.Circle.Stroke" Color="DarkGray"/> 
      <SolidColorBrush x:Key="Expander.Static.Arrow.Stroke" Color="#666"/> 
      <Style x:Key="ExpanderRightHeaderStyle" TargetType="{x:Type ToggleButton}"> 
       <Setter Property="Template"> 
        <Setter.Value> 
         <ControlTemplate TargetType="{x:Type ToggleButton}"> 
          <Border Padding="{TemplateBinding Padding}"> 
           <Grid Background="Transparent" SnapsToDevicePixels="False"> 
            <Grid.RowDefinitions> 
             <RowDefinition Height="19"/> 
             <RowDefinition Height="*"/> 
            </Grid.RowDefinitions> 
            <Grid> 
             <Grid.LayoutTransform> 
              <TransformGroup> 
               <TransformGroup.Children> 
                <TransformCollection> 
                 <RotateTransform Angle="-90"/> 
                </TransformCollection> 
               </TransformGroup.Children> 
              </TransformGroup> 
             </Grid.LayoutTransform> 
             <Ellipse x:Name="circle" Fill="{StaticResource Expander.Static.Circle.Fill}" HorizontalAlignment="Center" Height="19" Stroke="{StaticResource Expander.Static.Circle.Stroke}" VerticalAlignment="Center" Width="19"/> 
             <Path x:Name="arrow" Data="M 1,1.5 L 4.5,5 L 8,1.5" HorizontalAlignment="Center" SnapsToDevicePixels="false" Stroke="{StaticResource Expander.Static.Arrow.Stroke}" StrokeThickness="2" VerticalAlignment="Center"/> 
            </Grid> 
            <ContentPresenter HorizontalAlignment="Center" Margin="0,4,0,0" Grid.Row="1" RecognizesAccessKey="True" SnapsToDevicePixels="True" VerticalAlignment="Top"/> 
           </Grid> 
          </Border> 
          <ControlTemplate.Triggers> 
           <Trigger Property="IsChecked" Value="true"> 
            <Setter Property="Data" TargetName="arrow" Value="M 1,4.5 L 4.5,1 L 8,4.5"/> 
           </Trigger> 
           <Trigger Property="IsMouseOver" Value="true"> 
            <Setter Property="Stroke" TargetName="circle" Value="{StaticResource Expander.MouseOver.Circle.Stroke}"/> 
            <Setter Property="Fill" TargetName="circle" Value="{StaticResource Expander.MouseOver.Circle.Fill}"/> 
            <Setter Property="Stroke" TargetName="arrow" Value="{StaticResource Expander.MouseOver.Arrow.Stroke}"/> 
           </Trigger> 
           <Trigger Property="IsPressed" Value="true"> 
            <Setter Property="Stroke" TargetName="circle" Value="{StaticResource Expander.Pressed.Circle.Stroke}"/> 
            <Setter Property="StrokeThickness" TargetName="circle" Value="1.5"/> 
            <Setter Property="Fill" TargetName="circle" Value="{StaticResource Expander.Pressed.Circle.Fill}"/> 
            <Setter Property="Stroke" TargetName="arrow" Value="{StaticResource Expander.Pressed.Arrow.Stroke}"/> 
           </Trigger> 
           <Trigger Property="IsEnabled" Value="false"> 
            <Setter Property="Stroke" TargetName="circle" Value="{StaticResource Expander.Disabled.Circle.Stroke}"/> 
            <Setter Property="Fill" TargetName="circle" Value="{StaticResource Expander.Disabled.Circle.Fill}"/> 
            <Setter Property="Stroke" TargetName="arrow" Value="{StaticResource Expander.Disabled.Arrow.Stroke}"/> 
           </Trigger> 
          </ControlTemplate.Triggers> 
         </ControlTemplate> 
        </Setter.Value> 
       </Setter> 
      </Style> 
      <Style x:Key="ExpanderUpHeaderStyle" TargetType="{x:Type ToggleButton}"> 
       <Setter Property="Template"> 
        <Setter.Value> 
         <ControlTemplate TargetType="{x:Type ToggleButton}"> 
          <Border Padding="{TemplateBinding Padding}"> 
           <Grid Background="Transparent" SnapsToDevicePixels="False"> 
            <Grid.ColumnDefinitions> 
             <ColumnDefinition Width="19"/> 
             <ColumnDefinition Width="*"/> 
            </Grid.ColumnDefinitions> 
            <Grid> 
             <Grid.LayoutTransform> 
              <TransformGroup> 
               <TransformGroup.Children> 
                <TransformCollection> 
                 <RotateTransform Angle="180"/> 
                </TransformCollection> 
               </TransformGroup.Children> 
              </TransformGroup> 
             </Grid.LayoutTransform> 
             <Ellipse x:Name="circle" Fill="{StaticResource Expander.Static.Circle.Fill}" HorizontalAlignment="Center" Height="19" Stroke="{StaticResource Expander.Static.Circle.Stroke}" VerticalAlignment="Center" Width="19"/> 
             <Path x:Name="arrow" Data="M 1,1.5 L 4.5,5 L 8,1.5" HorizontalAlignment="Center" SnapsToDevicePixels="false" Stroke="{StaticResource Expander.Static.Arrow.Stroke}" StrokeThickness="2" VerticalAlignment="Center"/> 
            </Grid> 
            <ContentPresenter Grid.Column="1" HorizontalAlignment="Left" Margin="4,0,0,0" RecognizesAccessKey="True" SnapsToDevicePixels="True" VerticalAlignment="Center"/> 
           </Grid> 
          </Border> 
          <ControlTemplate.Triggers> 
           <Trigger Property="IsChecked" Value="true"> 
            <Setter Property="Data" TargetName="arrow" Value="M 1,4.5 L 4.5,1 L 8,4.5"/> 
           </Trigger> 
           <Trigger Property="IsMouseOver" Value="true"> 
            <Setter Property="Stroke" TargetName="circle" Value="{StaticResource Expander.MouseOver.Circle.Stroke}"/> 
            <Setter Property="Fill" TargetName="circle" Value="{StaticResource Expander.MouseOver.Circle.Fill}"/> 
            <Setter Property="Stroke" TargetName="arrow" Value="{StaticResource Expander.MouseOver.Arrow.Stroke}"/> 
           </Trigger> 
           <Trigger Property="IsPressed" Value="true"> 
            <Setter Property="Stroke" TargetName="circle" Value="{StaticResource Expander.Pressed.Circle.Stroke}"/> 
            <Setter Property="StrokeThickness" TargetName="circle" Value="1.5"/> 
            <Setter Property="Fill" TargetName="circle" Value="{StaticResource Expander.Pressed.Circle.Fill}"/> 
            <Setter Property="Stroke" TargetName="arrow" Value="{StaticResource Expander.Pressed.Arrow.Stroke}"/> 
           </Trigger> 
           <Trigger Property="IsEnabled" Value="false"> 
            <Setter Property="Stroke" TargetName="circle" Value="{StaticResource Expander.Disabled.Circle.Stroke}"/> 
            <Setter Property="Fill" TargetName="circle" Value="{StaticResource Expander.Disabled.Circle.Fill}"/> 
            <Setter Property="Stroke" TargetName="arrow" Value="{StaticResource Expander.Disabled.Arrow.Stroke}"/> 
           </Trigger> 
          </ControlTemplate.Triggers> 
         </ControlTemplate> 
        </Setter.Value> 
       </Setter> 
      </Style> 
      <Style x:Key="ExpanderLeftHeaderStyle" TargetType="{x:Type ToggleButton}"> 
       <Setter Property="Template"> 
        <Setter.Value> 
         <ControlTemplate TargetType="{x:Type ToggleButton}"> 
          <Border Padding="{TemplateBinding Padding}"> 
           <Grid Background="Transparent" SnapsToDevicePixels="False"> 
            <Grid.RowDefinitions> 
             <RowDefinition Height="19"/> 
             <RowDefinition Height="*"/> 
            </Grid.RowDefinitions> 
            <Grid> 
             <Grid.LayoutTransform> 
              <TransformGroup> 
               <TransformGroup.Children> 
                <TransformCollection> 
                 <RotateTransform Angle="90"/> 
                </TransformCollection> 
               </TransformGroup.Children> 
              </TransformGroup> 
             </Grid.LayoutTransform> 
             <Ellipse x:Name="circle" Fill="{StaticResource Expander.Static.Circle.Fill}" HorizontalAlignment="Center" Height="19" Stroke="{StaticResource Expander.Static.Circle.Stroke}" VerticalAlignment="Center" Width="19"/> 
             <Path x:Name="arrow" Data="M 1,1.5 L 4.5,5 L 8,1.5" HorizontalAlignment="Center" SnapsToDevicePixels="false" Stroke="{StaticResource Expander.Static.Arrow.Stroke}" StrokeThickness="2" VerticalAlignment="Center"/> 
            </Grid> 
            <ContentPresenter HorizontalAlignment="Center" Margin="0,4,0,0" Grid.Row="1" RecognizesAccessKey="True" SnapsToDevicePixels="True" VerticalAlignment="Top"/> 
           </Grid> 
          </Border> 
          <ControlTemplate.Triggers> 
           <Trigger Property="IsChecked" Value="true"> 
            <Setter Property="Data" TargetName="arrow" Value="M 1,4.5 L 4.5,1 L 8,4.5"/> 
           </Trigger> 
           <Trigger Property="IsMouseOver" Value="true"> 
            <Setter Property="Stroke" TargetName="circle" Value="{StaticResource Expander.MouseOver.Circle.Stroke}"/> 
            <Setter Property="Fill" TargetName="circle" Value="{StaticResource Expander.MouseOver.Circle.Fill}"/> 
            <Setter Property="Stroke" TargetName="arrow" Value="{StaticResource Expander.MouseOver.Arrow.Stroke}"/> 
           </Trigger> 
           <Trigger Property="IsPressed" Value="true"> 
            <Setter Property="Stroke" TargetName="circle" Value="{StaticResource Expander.Pressed.Circle.Stroke}"/> 
            <Setter Property="StrokeThickness" TargetName="circle" Value="1.5"/> 
            <Setter Property="Fill" TargetName="circle" Value="{StaticResource Expander.Pressed.Circle.Fill}"/> 
            <Setter Property="Stroke" TargetName="arrow" Value="{StaticResource Expander.Pressed.Arrow.Stroke}"/> 
           </Trigger> 
           <Trigger Property="IsEnabled" Value="false"> 
            <Setter Property="Stroke" TargetName="circle" Value="{StaticResource Expander.Disabled.Circle.Stroke}"/> 
            <Setter Property="Fill" TargetName="circle" Value="{StaticResource Expander.Disabled.Circle.Fill}"/> 
            <Setter Property="Stroke" TargetName="arrow" Value="{StaticResource Expander.Disabled.Arrow.Stroke}"/> 
           </Trigger> 
          </ControlTemplate.Triggers> 
         </ControlTemplate> 
        </Setter.Value> 
       </Setter> 
      </Style> 
      <Style x:Key="ExpanderHeaderFocusVisual"> 
       <Setter Property="Control.Template"> 
        <Setter.Value> 
         <ControlTemplate> 
          <Border> 
           <Rectangle Margin="0" SnapsToDevicePixels="true" Stroke="Black" StrokeThickness="1" StrokeDashArray="1 2"/> 
          </Border> 
         </ControlTemplate> 
        </Setter.Value> 
       </Setter> 
      </Style> 
      <Style x:Key="ExpanderDownHeaderStyle" TargetType="{x:Type ToggleButton}"> 
       <Setter Property="Template"> 
        <Setter.Value> 
         <ControlTemplate TargetType="{x:Type ToggleButton}"> 
          <Border Padding="{TemplateBinding Padding}"> 
           <Grid Background="Transparent" SnapsToDevicePixels="False"> 
            <Grid.ColumnDefinitions> 
             <ColumnDefinition Width="19"/> 
             <ColumnDefinition Width="*"/> 
            </Grid.ColumnDefinitions> 
            <Ellipse x:Name="circle" Fill="{StaticResource Expander.Static.Circle.Fill}" HorizontalAlignment="Center" Height="19" Stroke="{StaticResource Expander.Static.Circle.Stroke}" VerticalAlignment="Center" Width="19"/> 
            <Path x:Name="arrow" Data="M 1,1.5 L 4.5,5 L 8,1.5" HorizontalAlignment="Center" SnapsToDevicePixels="false" Stroke="{StaticResource Expander.Static.Arrow.Stroke}" StrokeThickness="2" VerticalAlignment="Center"/> 
            <ContentPresenter Grid.Column="1" HorizontalAlignment="Left" Margin="4,0,0,0" RecognizesAccessKey="True" SnapsToDevicePixels="True" VerticalAlignment="Center"/> 
           </Grid> 
          </Border> 
          <ControlTemplate.Triggers> 
           <Trigger Property="IsChecked" Value="true"> 
            <Setter Property="Data" TargetName="arrow" Value="M 1,4.5 L 4.5,1 L 8,4.5"/> 
           </Trigger> 
           <Trigger Property="IsMouseOver" Value="true"> 
            <Setter Property="Stroke" TargetName="circle" Value="{StaticResource Expander.MouseOver.Circle.Stroke}"/> 
            <Setter Property="Fill" TargetName="circle" Value="{StaticResource Expander.MouseOver.Circle.Fill}"/> 
            <Setter Property="Stroke" TargetName="arrow" Value="{StaticResource Expander.MouseOver.Arrow.Stroke}"/> 
           </Trigger> 
           <Trigger Property="IsPressed" Value="true"> 
            <Setter Property="Stroke" TargetName="circle" Value="{StaticResource Expander.Pressed.Circle.Stroke}"/> 
            <Setter Property="StrokeThickness" TargetName="circle" Value="1.5"/> 
            <Setter Property="Fill" TargetName="circle" Value="{StaticResource Expander.Pressed.Circle.Fill}"/> 
            <Setter Property="Stroke" TargetName="arrow" Value="{StaticResource Expander.Pressed.Arrow.Stroke}"/> 
           </Trigger> 
           <Trigger Property="IsEnabled" Value="false"> 
            <Setter Property="Stroke" TargetName="circle" Value="{StaticResource Expander.Disabled.Circle.Stroke}"/> 
            <Setter Property="Fill" TargetName="circle" Value="{StaticResource Expander.Disabled.Circle.Fill}"/> 
            <Setter Property="Stroke" TargetName="arrow" Value="{StaticResource Expander.Disabled.Arrow.Stroke}"/> 
           </Trigger> 
          </ControlTemplate.Triggers> 
         </ControlTemplate> 
        </Setter.Value> 
       </Setter> 
      </Style> 
      <Style x:Key="MatchExpanderStyle" TargetType="{x:Type Expander}"> 
       <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/> 
       <Setter Property="Background" Value="Transparent"/> 
       <Setter Property="HorizontalContentAlignment" Value="Stretch"/> 
       <Setter Property="VerticalContentAlignment" Value="Stretch"/> 
       <Setter Property="BorderBrush" Value="Transparent"/> 
       <Setter Property="BorderThickness" Value="1"/> 
       <Setter Property="Template"> 
        <Setter.Value> 
         <ControlTemplate TargetType="{x:Type Expander}"> 
          <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" CornerRadius="3" SnapsToDevicePixels="true"> 
           <DockPanel> 
            <ToggleButton x:Name="HeaderSite" Visibility="Hidden" ContentTemplate="{TemplateBinding HeaderTemplate}" ContentTemplateSelector="{TemplateBinding HeaderTemplateSelector}" Content="{TemplateBinding Header}" DockPanel.Dock="Top" Foreground="{TemplateBinding Foreground}" FontWeight="{TemplateBinding FontWeight}" FocusVisualStyle="{StaticResource ExpanderHeaderFocusVisual}" FontStyle="{TemplateBinding FontStyle}" FontStretch="{TemplateBinding FontStretch}" FontSize="{TemplateBinding FontSize}" FontFamily="{TemplateBinding FontFamily}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" IsChecked="{Binding IsExpanded, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" Margin="1" MinWidth="0" MinHeight="0" Padding="{TemplateBinding Padding}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"/> 
            <ContentPresenter x:Name="ExpandSite" DockPanel.Dock="Bottom" Focusable="false" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" Visibility="Collapsed" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/> 
           </DockPanel> 
          </Border> 
          <ControlTemplate.Triggers> 
           <Trigger Property="IsExpanded" Value="true"> 
            <Setter Property="Visibility" TargetName="ExpandSite" Value="Visible"/> 
           </Trigger> 
           <Trigger Property="ExpandDirection" Value="Right"> 
            <Setter Property="DockPanel.Dock" TargetName="ExpandSite" Value="Right"/> 
            <Setter Property="DockPanel.Dock" TargetName="HeaderSite" Value="Left"/> 
            <Setter Property="Style" TargetName="HeaderSite" Value="{StaticResource ExpanderRightHeaderStyle}"/> 
           </Trigger> 
           <Trigger Property="ExpandDirection" Value="Up"> 
            <Setter Property="DockPanel.Dock" TargetName="ExpandSite" Value="Top"/> 
            <Setter Property="DockPanel.Dock" TargetName="HeaderSite" Value="Bottom"/> 
            <Setter Property="Style" TargetName="HeaderSite" Value="{StaticResource ExpanderUpHeaderStyle}"/> 
           </Trigger> 
           <Trigger Property="ExpandDirection" Value="Left"> 
            <Setter Property="DockPanel.Dock" TargetName="ExpandSite" Value="Left"/> 
            <Setter Property="DockPanel.Dock" TargetName="HeaderSite" Value="Right"/> 
            <Setter Property="Style" TargetName="HeaderSite" Value="{StaticResource ExpanderLeftHeaderStyle}"/> 
           </Trigger> 
           <Trigger Property="IsEnabled" Value="false"> 
            <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/> 
           </Trigger> 
          </ControlTemplate.Triggers> 
         </ControlTemplate> 
        </Setter.Value> 
       </Setter> 
      </Style> 

Alles andere gleich bleibt wie bei älteren Antwort hier: How to bind a list of item in CollectionViewSource?

+0

Vielen Dank für diese, eigentlich kann ich Ihren Code nicht testen, ich werde es morgen versuchen. Nochmals vielen Dank :) – Heisenberg

+0

@lokusking siehe die Antwort plz – AnjumSKhan

+0

was passiert mit lokusking? Warum der Downvote? – Heisenberg

Verwandte Themen