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. [转]回答--python django学的很迷茫怎么办?

    作者:王一链接:http://www.zhihu.com/question/26235428/answer/36568428来源:知乎著作权归作者所有.商业转载请联系作者获得授权,非商业转载请注明出处 ...

  2. 使用VAssistX给文件和函数添加注释-2015.12.31

    在Visual Studio使用VAssistX助手可以非常方便的给文件和函数添加注释,增加更多的记录信息,从而方便在时间久后,对代码阅读理解的提示,以及别人后续对代码的维护和BUG修改. 添加头文件 ...

  3. WF4与MVC结合示例

    很多初学者,首先最想解决的问题是:如何将WF与MVC程序相结合.由于Web程序属于长时间运行的流程,因此持续化功能的运用就非常重要了. 本文将结合书签.WorkflowApplication.生命周期 ...

  4. oracle 游标示例

    declare iCount int:=0; sPath nvarchar2(200); tdzsh nvarchar2(50);begin for x in (select c.imgpath fr ...

  5. 线性回归的Spark实现 [Linear Regression / Machine Learning / Spark]

    1- 问题提出 2- 线性回归 3- 理论推导 4- Python/Spark实现 # -*- coding: utf-8 -*- from pyspark import SparkContext t ...

  6. IOS懒人笔记应用源码

    这个源码是懒人笔记应用源码,也是一个已经上线的apple应用商店的应用,懒人笔记iOS客户端源码,支持语音识别,即将语音转化成文本文字,所用语音识别类库为讯飞语音类库. 懒人笔记是一款为懒人设计的笔记 ...

  7. java编程思想第四版中 net.mindview.util包

    操作系统: win8.1 编译环境 JDK1.6 编辑器 notepad++ 第48页练习8 1 下载相应程序包 Thinking in Java 4ed - CODE 2 设置相应的CLASSPAT ...

  8. Creating a Unique File Name

    If you are working with files or file attachments in PeopleCode, you will typically want to create a ...

  9. Silverlight中本地化的实现(语言切换)

    对于本地化这个功能我个人一直觉得在需求阶段就要确定该项目需不需要实行本地化,这样后面就可以减轻许多工作量,Sl中对本地化功能的支持与ASP.NET 中一样,主要使用CultureInfo类来完成的. ...

  10. Ubuntu开发环境搭建

    linux开发不得不用虚拟机,为了节省系统资源.决定采用Ubuntu Server逐步搭建出具有图形界面的开发环境. ubuntu server 安装英文版 安装选择选generic,不要LVM选项. ...