DataTemplate ControlTemplate

  1. we can search many posts about this topic. some valuable link: DataTemplate和ControlTemplate的关系,
  2. 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.

  1. 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.

  1. ListBox.template : controltemplate

Controltemplate datatemplate的更多相关文章

  1. WPF ControlTemplate,DataTemplate

    The Control Template defines the visual appearance of a control. All of the UI elements have some ki ...

  2. 背水一战 Windows 10 (76) - 控件(控件基类): Control - 基础知识, 焦点相关, 运行时获取 ControlTemplate 和 DataTemplate 中的元素

    [源码下载] 背水一战 Windows 10 (76) - 控件(控件基类): Control - 基础知识, 焦点相关, 运行时获取 ControlTemplate 和 DataTemplate 中 ...

  3. WPF DataTemplate與ControlTemplate

    一. 前言     什麼是DataTemplate? 什麼是ControlTemplate? 在stackoverflow有句簡短的解釋 "A DataTemplate, therefore ...

  4. [No000012F]WPF(7/7) - 样式,触发器和动画

    WPF Tutorial : Beginning [^] WPF Tutorial : Layout-Panels-Containers & Layout Transformation [^] ...

  5. WPF 中那些可跨线程访问的 DispatcherObject(WPF Free Threaded Dispatcher Object)

    原文 WPF 中那些可跨线程访问的 DispatcherObject(WPF Free Threaded Dispatcher Object) 众所周知的,WPF 中多数对象都继承自 Dispatch ...

  6. WPF学习目录

    基本概念 数据源Source-目标Target WPF生命周期 App.xaml 依赖属性 WPF路由 线程操纵UI问题 利用属性中设置.查看DataContext/Command等 分析布局 写数据 ...

  7. WPf 带滚动条WrapPanel 自动换行 和控件右键菜单

    原文:WPf 带滚动条WrapPanel 自动换行 和控件右键菜单 技能点包括 WPf 样式的引用 数据的验证和绑定 比较适合初学者 前台: <Window.Resources> < ...

  8. WPF 判断一个对象是否是设计时的窗口类型,而不是运行时的窗口

    原文:WPF 判断一个对象是否是设计时的窗口类型,而不是运行时的窗口 当我们对 Window 类型写一个附加属性的时候,在属性变更通知中我们需要判断依赖对象是否是一个窗口.但是,如果直接判断是否是 W ...

  9. WPF源代码分析系列一:剖析WPF模板机制的内部实现(一)

    众所周知,在WPF框架中,Visual类是可以提供渲染(render)支持的最顶层的类,所有可视化元素(包括UIElement.FrameworkElment.Control等)都直接或间接继承自Vi ...

随机推荐

  1. Mac 平台下功能强大的Shimo软件使用指南

    年初自从换了MAC工作站后,彻底享受了Apple产品给我们带来的完美体验,可能是刚转过来不适应,在访问网络设备时觉得远程连接不方便,例如ssh,vpn登陆都不是很方便,后来又安装了openvpnfor ...

  2. UML的9种图例解析

    摘自: http://blog.csdn.net/fatherican/article/details/44966891 UML图中类之间的关系:依赖,泛化,关联,聚合,组合,实现 类与类图 1) 类 ...

  3. 智能手机取证利器再进化-UFED Cloud Analyzer

    智能手机在现代人生活中,和钱包,钥匙一样,成了不可或缺的生活必需品,举凡食衣住行育乐都需要携带随身使用,因此,智能手机里所存放的,就是一个人的生活缩影,只是人们多半不自知智能手机竟是如此贴心的为你/妳 ...

  4. Android SQLite数据储存方式

    SQLiteOpenHelper 类 用SQLiteOpenHelper 类中的 getWritableDatabase()和getReadableDatabase()方法可以获得数据库的引用. 为了 ...

  5. Solaris磁盘设备

    Solaris的磁盘分区称为分片(slice),在磁盘上,一个环形就是一个分区分片的命名通常是c#t#d#s#c:Controller number,控制器标号,c0就是第一个控制器t:Taget n ...

  6. AnyCAD三维控件场景节点详解

    SceneNode是AnyCAD三维图形平台的AnyViz显示引擎的核心对象之一,只有放在场景管理器(SceneManager)里的节点才能被显示引擎所显示. 1.   节点分类 SceneNode是 ...

  7. IPHONE 字体加粗

    UIFONT 没有字体加精参数,但可以修发,字体名,达到加粗的效果正常:Helvetica加粗"Helvetica-Bold""TimesNewRomanPS-BoldM ...

  8. c#中$.ajax的使用

      <script type="text/javascript">  var telphone = { type: "getphone", &quo ...

  9. jquery 获取元素坐标

    不错哦! 原文地址:http://jianzhong5137.blog.163.com/blog/static/9829049201182295833503/ 绝对X,Y坐标,可以用offset()方 ...

  10. url 编码(percentcode 百分号编码)

    http://www.imkevinyang.com/2009/08/%E8%AF%A6%E8%A7%A3javascript%E4%B8%AD%E7%9A%84url%E7%BC%96%E8%A7% ...