WPF implements ListView size icons and groups, wpflistview
XAML:
<ListView Grid. row = "3" Name = "t_lvw_time" HorizontalAlignment = "Stretch" verticalignment = "Stretch" ScrollViewer. verticalScrollBarVisibility = "Auto" ScrollViewer. horizontalScrollBarVisibility = "Disabled" PreviewMouseDown = "t_lvw_time_PreviewMouseMove" AllowDrop = "True" DragOver = "t_lvw_time_DragEnter" SelectionMode = "Extended"> <ListView. itemsPanel> <ItemsPanelTemplate> <WrapPanel IsItemsHost = "True"/> </ItemsPanelTemplate> </ListView. itemsPanel> <ListView. itemTemplate> <DataTemplate> <Grid Width = "125" Height = "70"> <Grid. rowDefinitions> <RowDefinition/> </Grid. rowDefinitions> <Image Source = "/ExtendSmartVTWPF; component/Images/go_home.png "HorizontalAlignment =" Center "/> <TextBlock Text =" {Binding Path = room_code} "TextWrapping =" Wrap "Grid. row = "1" HorizontalAlignment = "Center"/> </Grid> </DataTemplate> </ListView. itemTemplate> <ListView. groupStyle> <GroupStyle. containerStyle> <Style TargetType = "{x: Type GroupItem}"> <Setter Property = "Template"> <Setter. value> <ControlTemplate TargetType = "{x: Type GroupItem}"> <Expander IsExpanded = "True" BorderBrush = "# B5B5B5" BorderThickness = "0, 0, 1"> <Expander. header> <DockPanel> <TextBlock FontWeight = "Bold" Text = "{Binding Path = Name}" Margin = "5, 0, 150 "Width =" "/> <TextBlock FontWeight =" Bold "Text =" Quantity: "Margin =, 0, 0 "Width =" 50 "/> <TextBlock FontWeight =" Bold "Text =" {Binding Path = ItemCount} "Margin =" 5, 0, 150 "Width =" "/> </DockPanel> </Expander. header> <Expander. content> <Grid. rowDefinitions> <RowDefinition> </Grid. rowDefinitions> <ItemsPresenter Grid. row = "0"/> </Grid> </Expander. content> </Expander> </ControlTemplate> </Setter. value> </Setter> </Style> </GroupStyle. containerStyle> </GroupStyle> </ListView. groupStyle> </ListView>
Background:
List <T> list = GetList (); var sourceView = new ListCollectionView (list); var groupDesctripition = new PropertyGroupDescription ("room_code"); // group by room_code, room_code is the property sourceView in the set. groupDescriptions. add (groupDesctripition); listview1.ItemsSource = sourceView;
Instance image: