zoukankan      html  css  js  c++  java
  • WPF实现ListView大小图标和分组

    XAML:
    <ListView Grid.Row="3" Name="t_lvw_time" HorizontalAlignment="Stretch" VerticalAlignment="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/>
                                <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>
                            <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,0,1">
                                                    <Expander.Header>
                                                        <DockPanel>
                                                            <TextBlock FontWeight="Bold" Text="{Binding Path=Name}" Margin="5,0,0,0" Width="150"     />
                                                        <TextBlock FontWeight="Bold" Text="数量:" Margin="0,0,0,0" Width="50"     />
                                                        <TextBlock FontWeight="Bold" Text="{Binding Path=ItemCount}" Margin="5,0,0,0" Width="150"     />
                                                    </DockPanel>
                                                    </Expander.Header>
                                                     <Expander.Content>
                                                        <Grid>
                                                            <Grid.RowDefinitions>
                                                                <RowDefinition ></RowDefinition>
                                                                <RowDefinition></RowDefinition>
                                                            </Grid.RowDefinitions>
                                                            <ItemsPresenter Grid.Row="0"/>
                                                            </Grid>
                                                    </Expander.Content>
                                                </Expander>
                                            </ControlTemplate>
                                        </Setter.Value>
                                    </Setter>
                                </Style>
                            </GroupStyle.ContainerStyle>
                        </GroupStyle>
                    </ListView.GroupStyle>
                </ListView>
    

     后台:

                List<T> list=GetList();
                var sourceView = new ListCollectionView(list);
                var groupDesctripition = new PropertyGroupDescription("room_code");//按room_code分组,room_code为集合中的属性
                sourceView.GroupDescriptions.Add(groupDesctripition);
                listview1.ItemsSource = sourceView;
    

    实例图片:

  • 相关阅读:
    ubuntu操作技巧
    电机
    哈佛结构与冯若依曼结构
    linux command ------ ls
    Frames of Reference参考框架
    What Are Tango Poses?Tango姿态是什么?
    Google Tango Java SDK开发:Motion Tracking 运动追踪
    Google Tango Java SDK开发:Configure and Connect 配置和连接
    gradle
    Google Tango service outdated谷歌Tango的服务过时了
  • 原文地址:https://www.cnblogs.com/dingguidong/p/4342313.html
Copyright © 2011-2022 走看看