DataTemplate——数据模板的一个典型例子
下面是ListBox.ItemTemplate(数据模板)应用的“典型”例子,概述如下两点:
1:Grid部分,用来“规划” 数据 显示的 布局(即数据长成什么样子)
2:给DataTemplate添加触发器(即给Item添加了触发器),因此联想到,也可以给ControlTemplate添加触发器。
<ListBox.ItemTemplate>
<DataTemplate DataType="TwoLevelTreeNodeViewModel">
<--Grid部分,“规划” 数据 以 何种 样子 展现出来-->
<Grid>
<Grid.Background>
<ImageBrush AlignmentX="Left" AlignmentY="Top" TileMode="Tile" ViewportUnits="Absolute" Viewport="0,0,229,42" ImageSource="/FounderAMP;component/Images/Police/SearchResult_bg.png"/>
</Grid.Background>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="11"/>
</Grid.ColumnDefinitions>
<Rectangle Name="selectedBackground" Fill="#3d7cff" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.Column="0" Grid.ColumnSpan="2" Visibility="Collapsed"/>
<TextBlock Name="headerLabel" Text="{Binding Path=HeaderText}" Grid.Column="0" TextTrimming="WordEllipsis" ToolTip="{Binding Path=HeaderText}" HorizontalAlignment="Stretch" TextAlignment="Left" VerticalAlignment="Center" Margin="8,0,0,0" Width="200" FontFamily="Microsoft YaHei" FontSize="13" />
<TextBlock Name="footerLabel" ToolTip="{Binding Path=FooterText}" TextTrimming="WordEllipsis" Text="{Binding Path=FooterText}" Grid.Column="0" HorizontalAlignment="Right" VerticalAlignment="Center" FontFamily="Microsoft YaHei" FontSize="13" FontWeight="Bold" Margin="0,0,6,0" />
<Image Source="/FounderAMP;component/Images/Police/Downward_Triangle.png" Grid.Column="1" Cursor="Hand" Visibility="{Binding Path=ExpandingVisibility}" Name="ExpandOrgNodeImage" MouseLeftButtonDown="ExpandOrgNodeImage_MouseLeftButtonDown" Tag="{Binding}"/>
</Grid>
<--给DataTemplate添加触发器(即给Item添加了触发器)-->
<DataTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True"><-- 由于该DataTemplate 是为ListBox.ItemTemplate定义的,所以当鼠标悬停在“Item”上时,会“激发”该触发器
<Setter TargetName="selectedBackground" Property="Visibility" Value="Visible"/>
<Setter TargetName="headerLabel" Property="Foreground" Value="White"/>
<Setter TargetName="footerLabel" Property="Foreground" Value="White"/>
<Setter TargetName="ExpandOrgNodeImage" Property="Source" Value="/FounderAMP;component/Images/Police/downwardTriangle_WhiteBackground.png"/>
</Trigger>
</DataTemplate.Triggers>
</DataTemplate>
</ListBox.ItemTemplate>
DataTemplate——数据模板的一个典型例子的更多相关文章
- Java基础(9):Java生成随机数一定范围内的数的一个典型例子
题目:编写一个JAVA程序,创建指定长度的 int 型数组,并生成 100 以内随机数为数组中的每个元素赋值,然后输出数组 note: 通过 (int)(Math.random() * 100) 生成 ...
- WebDriver+TestNG的一个典型例子
想让测试更加灵活,1. 可以配置使用任意支持的浏览器进行测试:2. 配置所有Google的URL:3. 配置搜索的关键字.修改后的代码: public class GoogleTest { WebDr ...
- WPF中的数据模板(DataTemplate)(转)
原文地址 http://www.cnblogs.com/zhouyinhui/archive/2007/03/30/694388.html WPF中的数据模板(DataTemplate) ...
- WPF中的数据模板(DataTemplate)
原文:WPF中的数据模板(DataTemplate) WPF中的数据模板(DataTemplate) ...
- WPF 后台获得 数据模板里的内容控件(DataTemplate)
原文:WPF 后台获得 数据模板里的内容控件(DataTemplate) 假如 <Window.Resources> 里 有一个 Datatemplate 我想获得TextBlo ...
- 把采集到的数据发送到一个Google Docs或者Google Form上 这个网站提供了参考和例子
把采集到的数据发送到一个Google Docs或者Google Form上这个网站提供了参考和例子 http://www.instructables.com/id/Post-to-Google-Doc ...
- Windows Phone开发(14):数据模板
原文:Windows Phone开发(14):数据模板 数据模板,如果你仅仅听到这个名词,你一定很迷惑,什么来的?用来干什么的?不急,亲,今天,我们一起来探索一下吧. 用白话文说,数据模板就是用来规范 ...
- Anaconda安装Graphviz, mac下Graphviz安装, pcharm中调用pycharm, Graphviz典型例子
mac下的Graphviz安装及使用 2017年10月13日 13:30:07 阅读数:7495 一.安装 Graphviz http://www.graphviz.org/ mac用户建议直接用ho ...
- FreeMarker数据模板引擎全面教程mark
http://blog.csdn.net/fhx007/article/details/7902040/#comments 以下内容全部是网上收集: FreeMarker的模板文件并不比HTML页面复 ...
随机推荐
- 3D游戏引擎中常见的三维场景管理方法
对于一个有很多物体的3D场景来说,渲染这个场景最简单的方式就是用一个List将这些物体进行存储,并送入GPU进行渲染.当然,这种做法在效率上来说是相当低下的,因为真正需要渲染的物体应该是视椎体内的物体 ...
- shiro的/favicon.ico问题
登录成功之后跳转/favicon.ico问题. 1.spring-shrio.xml里面配置加上 /favicon.ico = anon 2.web.xml中配置中加上: <mime-mappi ...
- UVA10100:Longest Match(最长公共子序列)&&HDU1458Common Subsequence ( LCS)
题目链接:http://blog.csdn.net/u014361775/article/details/42873875 题目解析: 给定两行字符串序列,输出它们之间最大公共子单词的个数 对于给的两 ...
- Jmeter+jenkins如何快速搭建接口和性能测试持续集成解决方案-[基于windows篇]
最近在用Jmeter本来想写一个详细的使用教程,突然看到有前辈已经写好了不错的教程,特此"借花献佛"整理出来分享给大家! Jenkins + Jmeter 构建接口.性能测试持续集 ...
- 深入跟踪MFC程序的执行流程
来源: http://blog.csdn.net/ljianhui/article/details/8781991 在MFC程序设计的学习过程中最令人感到难受,甚至于有时会动摇学习者信心的就是一种对于 ...
- Delphi APP 開發入門(七)通知與雲端推播
Delphi APP 開發入門(七)通知與雲端推播 分享: Share on facebookShare on twitterShare on google_plusone_share 閲讀次數: ...
- Java基础知识陷阱(五)
本文发表于本人博客. 今天我来说说关于静态变量初始化.数组.==与equals的问题,看下面代码: public class Test{ private final int age; private ...
- 1.MySQL必知必会之数据库基础
下面这几个是几个关于数据库的关键字的概念,为后面的教程做基础的: 数据库:保存有组织的数据的容器(通常是一个文件或一组文件). 表: 某种特定类型数据的结构化清单. 模式:关于数据库和表的布局 ...
- PHP下使用Redis消息队列发布微博(复制)
phpRedisAdmin :github地址 图形化管理界面 git clone https://github.com/ErikDubbelboer/phpRedisAdmin.git cd ph ...
- Spring-1-H Number Sequence(HDU 5014)解题报告及测试数据
Number Sequence Time Limit:2000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Pro ...