Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

WPF How to Enable/Disable Grouping for ListView in C#

$
0
0

Hello,
I need some advice. I have a ListView, which ranks the items into groups. These groups can be dynamic and enable / disable

<ListView Name="ProjectsList" ItemsSource="{Binding Data}">

<ListView.GroupStyle><GroupStyle ><GroupStyle.ContainerStyle><Style TargetType="{x:Type GroupItem}"><Setter Property="Template"><Setter.Value><ControlTemplate TargetType="{x:Type GroupItem}"><Grid Name="GridRot"><Grid.RowDefinitions><RowDefinition /><RowDefinition /></Grid.RowDefinitions><Border Grid.Row="0"><Grid><TextBlock Background="Gray" DataContext="{Binding Items}"><Run Text="{Binding Name}" FontSize="16"/><Run Text=" "/><Run Text=":"/><Run Text=" "/><Run Text="{Binding Nickname}"/></TextBlock></Grid></Border><ItemsPresenter Grid.Row="1" Margin="20,0,0,0" /></Grid></ControlTemplate></Setter.Value></Setter></Style></GroupStyle.ContainerStyle></GroupStyle></ListView.GroupStyle>

<ListView.ItemTemplate><DataTemplate><Grid><TextBlock FontWeight="Bold" FontSize="14" Text="{Binding Name}"/></Grid></DataTemplate></ListView.ItemTemplate><ListView.ItemContainerStyle><Style TargetType="{x:Type ListViewItem}"><Setter Property="Template"><Setter.Value><ControlTemplate TargetType="ListViewItem"><Grid Focusable="False" ><Rectangle Focusable="False" Fill="{TemplateBinding Background}" /><ContentPresenter Margin="10" /></Grid></ControlTemplate></Setter.Value></Setter><Style.Triggers><Trigger Property="IsMouseOver" Value="True"><Setter Property="Background" Value="Gray" /></Trigger><Trigger Property="IsSelected" Value="True"><Setter Property="Background" Value="LightBlue" /></Trigger></Style.Triggers></Style></ListView.ItemContainerStyle></ListView>


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>