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)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • Hadoop面试题[通俗易懂]

    Hadoop面试题[通俗易懂]文章目录你们公司集群有多少机器,内存,硬盘,CPU?你们Hadoop、Hive、Kafka都是什么版本?你们每天的数据量有多少?数据总量是多少?分布式和集群的区别?Hadoop1和Hadoop2的区别?Hadoop1Hadoop2NameNode运行处理什么是Hadoop?说一说Hadoop的shuffle过程?Hadoop中为什么需要排序?HDFS相关概念特点缺点BlockNameNodeDataNodeEditLogFSImageSecondaryNameNodefsimage和edits合

    2022年6月29日
    24
  • 谷歌网盘扩容价格_谷歌云盘无限容量

    谷歌网盘扩容价格_谷歌云盘无限容量如何不用信用卡也不用PayPal来对谷歌网盘扩容呢?

    2025年10月11日
    4
  • response的contentType的类型值

    response的contentType的类型值转自:http://blog.csdn.net/andyzhaojianhui/article/details/72875698本文导读:ContentType属性指定服务器响应的HTTP内容类型。如果未指定ContentType,默认为text/html。response的ContentType()的作用是使客户端浏览器,区分不同种类的数据,并根据不同的MI

    2022年7月19日
    22
  • Laravel 传递数据到视图

    Laravel 传递数据到视图

    2021年10月26日
    41
  • 【算法题】单例模式的8种实现方式(java版)「建议收藏」

    【算法题】单例模式的8种实现方式(java版)「建议收藏」根据马士兵老师的视频整理下来的8种单例模式的实现方式,在此记录一下。代码示例1:饿汉式packagecom.examples.singleton;publicclassMgr01{publicstaticvoidmain(String[]args){Mgr01m1=Mgr01.getInstance();Mgr01m2=Mgr01.getInstance();System.out.println(m1…

    2022年7月8日
    22
  • 安卓系统文件夹结构及其文件解析(详细)_不压缩文件夹设置密码

    安卓系统文件夹结构及其文件解析(详细)_不压缩文件夹设置密码安卓系统文件夹结构详解核system\\app这个里面主要存放的是常规下载的应用程序,可以看到都是以APK格式结尾的文件。在这个文件夹下的程序为系统默认的组件,自己安装的软件将不会出现在这里,而是\\data\\文件夹中。下面是详细的介绍:\\system\\app\\AlarmClock.apk闹钟\\system\\app\\AlarmClock.odex\\system\\…

    2022年10月9日
    3

发表回复

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

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