WPF implements ListView size icons and groups, wpflistview

Source: Internet
Author: User

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:

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.