Controltemplate datatemplate
DataTemplate ControlTemplate
- we can search many posts about this topic. some valuable link: DataTemplate和ControlTemplate的关系,
- we can see some definition about ControlTemplate, DataTemplate, HierarchicalDataTemplate
2.1. A ControlTemplate is used to define/change the way a class derived from Control looks, such as Buttons, ListBox, ScrollBar. However, some "Controls" you use are not derived from Control: Best example is the TextBlock class. The TextBlock cannot have a ControlTemplate.
ControlTemplate is connected to the Template property of the Control, we can set it directly to the property.
2.2 DataTemplate is closelly linked with the “Content” in WPF. Certain controls are made to display "Content". Content can be anything, such as Image, Text, Object.... in fact, it is defined as an "object" type. The DataTemplate simply defines how a particular content (or content type) is meant to be displayed.
DataTemplate is used to display Content of a Control, the Relative property is CellTemplate,ContentTemplate,ItemTemplate.
2.3. HierarchicalDataTemplate is an extension of DataTemplate with an additional ItemSource property. It is used to render hierarchical data in controls like treeview or menu.
Example: Usually, a string is displayed using a simple TextBlock... However, if you want a custom text layout, decoration, alignement, ... you would need to define an Alternate DataTemplate.
- the relationship of these concept.
Control类型
- Template属性 (ControlTemplate类型)
- ContentPresenter
- ContentTemplate (DataTemplate类型)
ContentControl类型
- Template属性 (ControlTemplate类型) 继承自Control
- ContentTemplate (DataTemplate类型)
ItemsControl类型
- Template属性 (ControlTemplate类型) 继承自Control
- ItemsPanel属性 (ItemsPanelTemplate类型) 指定布局容器
- ItemTemplate属性 (DateTemplate类型) 每个Item的Template
***
ListBox controltemplate Datatemplate.
- ListBox.template : controltemplate
Controltemplate datatemplate的更多相关文章
- WPF ControlTemplate,DataTemplate
The Control Template defines the visual appearance of a control. All of the UI elements have some ki ...
- 背水一战 Windows 10 (76) - 控件(控件基类): Control - 基础知识, 焦点相关, 运行时获取 ControlTemplate 和 DataTemplate 中的元素
[源码下载] 背水一战 Windows 10 (76) - 控件(控件基类): Control - 基础知识, 焦点相关, 运行时获取 ControlTemplate 和 DataTemplate 中 ...
- WPF DataTemplate與ControlTemplate
一. 前言 什麼是DataTemplate? 什麼是ControlTemplate? 在stackoverflow有句簡短的解釋 "A DataTemplate, therefore ...
- [No000012F]WPF(7/7) - 样式,触发器和动画
WPF Tutorial : Beginning [^] WPF Tutorial : Layout-Panels-Containers & Layout Transformation [^] ...
- WPF 中那些可跨线程访问的 DispatcherObject(WPF Free Threaded Dispatcher Object)
原文 WPF 中那些可跨线程访问的 DispatcherObject(WPF Free Threaded Dispatcher Object) 众所周知的,WPF 中多数对象都继承自 Dispatch ...
- WPF学习目录
基本概念 数据源Source-目标Target WPF生命周期 App.xaml 依赖属性 WPF路由 线程操纵UI问题 利用属性中设置.查看DataContext/Command等 分析布局 写数据 ...
- WPf 带滚动条WrapPanel 自动换行 和控件右键菜单
原文:WPf 带滚动条WrapPanel 自动换行 和控件右键菜单 技能点包括 WPf 样式的引用 数据的验证和绑定 比较适合初学者 前台: <Window.Resources> < ...
- WPF 判断一个对象是否是设计时的窗口类型,而不是运行时的窗口
原文:WPF 判断一个对象是否是设计时的窗口类型,而不是运行时的窗口 当我们对 Window 类型写一个附加属性的时候,在属性变更通知中我们需要判断依赖对象是否是一个窗口.但是,如果直接判断是否是 W ...
- WPF源代码分析系列一:剖析WPF模板机制的内部实现(一)
众所周知,在WPF框架中,Visual类是可以提供渲染(render)支持的最顶层的类,所有可视化元素(包括UIElement.FrameworkElment.Control等)都直接或间接继承自Vi ...
随机推荐
- 二模07day2解题报告
T1.采药(medic) 有n个草药,要在m的时间内获得最大价值. 乍一看像是01背包,然而数据只能过50分. 考虑数据范围,t<=10,w<=10,所以只有121种草药.考虑多重背包的二 ...
- 【MySQl】MyISAM和InnoDB索引对比
部分内容转自:http://www.2cto.com/database/201211/172380.html 比较好的文章:http://www.cnblogs.com/hustcat/archive ...
- asp.net常用字符串函数
/// <summary> /// 提取字符串中的数字 /// </summary> /// <param name="str"></pa ...
- WP8_GestureListener实现列表向下滑动加载新数据
利用GestureListener的OnDragCompleted事件,实现列表向下滑动时,加载新的数据: (不建议使用 Touch.FrameReported+=Touch_FrameReporte ...
- Something wrong with FTK OCR
A case about business secret the suspect took lots of photos and screenshots from BOM, RD papers... ...
- ipv4、ipv6的socket同时监听“bind: Address already in use”的解决方法
创建ipv4和ipv6的socket,同时监听某个端口的ipv4和ipv6报文,运行时bind函数执行失败,提示“bind: Address already in use”.原因:ipv6的socke ...
- 【Linux】程序内获取文件系统挂载信息
Linux shell可通过查看/etc/mtab或者/proc/mounts文件来获取当前文件系统挂载信息,示例: 程序内读取/etc/mtab或者/proc/mounts,解析字符串较为繁琐,可以 ...
- VBA表格单元格替换文字
Sub 表格单元格替换文字() If MsgBox("确定要替换单元格的文字吗?", vbYesNo + vbQuestion) = vbYes Then To ActiveDoc ...
- iOS中UIKit——UIDataDetectors(数据检测器)它将电话、邮件、网址等变为链接
1.它用于UITextView和UIWebView,属性名为:dataDetetorTypes 2.此属性可以设定使符合电话.邮件.网址.符合格式的日期等文字变为链接文字. 3.电话号码点击后拨出电话 ...
- Dev的DocumentManager添加窗体
1.DocumentManager要设置自己的MdiParent属性 2.主窗体设置IsMidContainer为True 3.要生成的窗体设置MdiParent为主窗体 4.正常创建窗体,然后就可以 ...