Styling a ListView with a Horizontal ItemsPanel and a Header

Styling a ListView with a Horizontal ItemsPanel and a Header

原文 http://eblog.cloudplush.com/2012/05/23/styling-a-listview-with-a-horizontal-itemspanel-and-a-header/

I had to create a specific ListView for my WPF project. A Horizontal alignment of items, with a header column, containing a templated item with a templated checkbox. The final effect looks like this:

Styling a ListView with a Horizontal ItemsPanel and a Header

If we decompose the panel, here are the elements:
Black box: ListView with Template containing a Grid with 2 columns
Red box: The Header column in the ListView template on Grid.Column=”0″
Yellow box: The ListView item panel (ItemsPresenter) located on Grid.Column=”1″ containing an templates ItemsPanelTemplate which is a StackPanel with an Orientation=”Horizontal”.
Green box: The ListView’s ItemTemplate which is a StackPanel with an Orientation=”Vertical” containing a TextBlock with a RotateTransform LayoutTransform and a Templated Checkbox which uses an Ellipse as it’s main shape.

Styling a ListView with a Horizontal ItemsPanel and a Header

<ListView ItemsSource="{Binding OpUnitList}" Grid.Row="1" Name="FilterListBox">
 <ListView.ItemsPanel>
   <ItemsPanelTemplate>
     <StackPanel Orientation="Horizontal" IsItemsHost="True">
     </StackPanel>
   </ItemsPanelTemplate>
 </ListView.ItemsPanel>
 <ListView.ItemTemplate>
   <DataTemplate>
     <StackPanel Orientation="Vertical">
       <TextBlock Text="{Binding OpUnitName}" Width="60" Margin="2">
         <TextBlock.LayoutTransform>
           <RotateTransform Angle="-90"/>
         </TextBlock.LayoutTransform>
       </TextBlock>
       <CheckBox IsChecked="{Binding FilterValue}" Name="RgDot" IsThreeState="True" Style="{StaticResource EllipseCheckBoxStyle}"/>
     </StackPanel>
   </DataTemplate>
 </ListView.ItemTemplate>
 <ListView.Template>
   <ControlTemplate>
     <Grid HorizontalAlignment="Left"> 
       <Grid.ColumnDefinitions>
         <ColumnDefinition Width="Auto"></ColumnDefinition>
         <ColumnDefinition Width="*"></ColumnDefinition>
       </Grid.ColumnDefinitions>
       <StackPanel Orientation="Vertical" Grid.Column="0">
         <TextBlock Margin="2" Height="60">OpUnit Name</TextBlock>
         <TextBlock Margin="2">Filter</TextBlock>
       </StackPanel>
       <ItemsPresenter Grid.Column="1"></ItemsPresenter>
     </Grid>
   </ControlTemplate>
 </ListView.Template>
</ListView>

 

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/101581.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 关于记忆化搜索

    关于记忆化搜索转载自:http://blog.csdn.net/urecvbnkuhbh_54245df/article/details/5847876记忆化搜索: 算法上依然是搜索的流程,但是搜索到的一些解用动态规划的那种思想和模式作一些保存。一般说来,动态规划总要遍历所有的状态,而搜索可以排除一些无效状态。更重要的是搜索还可以剪枝,可能剪去大量不必要的状态,因此在空间开销上往往比动

    2022年7月26日
    9
  • Linux操作系统平台Vi指令大全

    Linux操作系统平台Vi指令大全

    2021年7月28日
    62
  • Linux:Tomcat部署war包

    Linux:Tomcat部署war包1、xftp上传Tomcat2、解压Tomcat:tar-zvxf文件unzip文件等解压命令3、将war包放在Tomcat中的webapps目录下(如果webapps中有任何其他war包或解压后的文件都需要删除)4、修改以上穿过去的文件的拥有者(非root用户下时)5、查看需要使用的端口的占用情况(ro…

    2025年7月4日
    2
  • php每秒执行一次_crontab每分钟执行shell脚本

    php每秒执行一次_crontab每分钟执行shell脚本作为php-slimWeb应用程序的一部分,在我的init.php文件中,我需要一个Crontab.php,其中包含以下代码://clearsanyexistingcrontabjobsfirstexec(“crontab-r”);$ctCommand='”*/1****php./ProcessCycleTimeData.php”‘;exec(“(crontab-…

    2022年8月30日
    4
  • python 去掉文件后缀名,python 删除后缀名文件

    python 去掉文件后缀名,python 删除后缀名文件Note:print语句供test用#!/usr/bin/pythonimportos,re,time,sysimportos.pathimportstringfilter_dir=”/home/fengnazh/splittest/files/”filterfile_list=os.listdir(filter_dir)printfilterfile_listfile_i…

    2022年5月7日
    331
  • matlab 及数字信号实验报告,Matlab数字信号处理实验报告.doc

    您所在位置:网站首页>海量文档&nbsp>&nbsp高等教育&nbsp>&nbsp实验设计Matlab数字信号处理实验报告.doc26页本文档一共被下载:次,您可全文免费在线阅读后下载本文档。下载提示1.本站不保证该用户上传的文档完整性,不预览、不比对内容而直接下载产生的反悔问题本站不予受理。2.该文档所得收入…

    2022年4月8日
    51

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号