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


相关推荐

  • 使用 HTML、CSS 和 JS 创建在线音乐播放器(含免费完整源码)

    使用 HTML、CSS 和 JS 创建在线音乐播放器(含免费完整源码)直接跳到末尾获取完整源码今天我将带着大家使用HTML、CSS和JS创建音乐播放器,没有使用任何其他库。我们的音乐播放器具有三个部分。主屏幕、播放器部分和播放列表部分。我们的主页部分有一个平滑的工作滑块,也有水平滚动。这个音乐播放器最好的部分是它最小化了音乐播放器。是的,您可以最小化和最大化播放器本身。使这个项目成为一个很棒的音乐播放器。❤️使用HTML、CSS和JS创建在线音乐播放器❤️????在线演示地址????完整代码结构????home-section首页部分???

    2022年6月26日
    60
  • pycharm2022.01.13怎么激活_在线激活[通俗易懂]

    (pycharm2022.01.13怎么激活)这是一篇idea技术相关文章,由全栈君为大家提供,主要知识点是关于2021JetBrains全家桶永久激活码的内容https://javaforall.net/100143.htmlIntelliJ2021最新激活注册码,破解教程可免费永久激活,亲测有效,上面是详细链接哦~1PA3AFINM4-eyJsaWNlb…

    2022年3月31日
    59
  • CentOS7安装MySQL8.0.12(mysql8版本有的地方还是有坑想好再用)

    CentOS7安装MySQL8.0.12(mysql8版本有的地方还是有坑想好再用)

    2021年6月1日
    115
  • 42步进电机转速力矩曲线_步进电机的力矩与转速

    42步进电机转速力矩曲线_步进电机的力矩与转速扭矩是指步进电机运转时从输出轴的平均力矩,俗称为步进电机的“转劲”。扭矩越大,步进电机输出的“劲”越大,输出轴转速的变化也越快。扭矩随步进电机转速的变化而不同,转速太高或太低,扭矩都不是最大,只在某个转速时或某个转速区间内才有最大扭矩,这个区间就是在标出最大扭矩时给出的转速或转速区间。最大扭矩一般出现在步进电机的中、低转速的范围,随着转速的提高,扭矩反而会下降。扭矩的单位是牛顿·米(N·m)或公斤…

    2022年5月14日
    107
  • Excel 增加删除线

    Excel 增加删除线Excel增加删除线操作如下:2.选中删除线即增加删除线,去掉删除线即删除删除线,颜色可以定义成红色之类。

    2022年8月3日
    3
  • JMM 详解_jmm是什么意思

    JMM 详解_jmm是什么意思多任务和高并发的内存交互多任务和高并发是衡量一台计算机处理器的能力重要指标之一。一般衡量一个服务器性能的高低好坏,使用每秒事务处理数(TransactionsPerSecond,TPS)这个指标比较能说明问题,它代表着一秒内服务器平均能响应的请求数,而TPS值与程序的并发能力有着非常密切的关系。物理机的并发问题与虚拟机中的情况有很多相似之处,物理机对并发的处理方案对于虚拟机的实现也有相

    2022年9月5日
    3

发表回复

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

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