"Essential WPF - Chapter 7 Actions" 阅读笔记

原创 2011年01月21日 13:10:00

Chapter 7 Actions


Up to now we have focused on the output side of the platform, looking at how an application is built up from controls that use visuals to display and layout to position everything.


Now we can start to look at the input side of the platform.


WPF Actions: events, commands, and triggers.


Action Principles: element composition, loose coupling, and declarative actions.


7.1 Action Principles


To allow actions to work with the way that WPF builds the display tree, with many elements that may be further composed of other elements, requires the use of element composition.


routed event 原来是来自于 element composition 引入的 event 处理难题

"Routed events are events that are designed to work well with a tree of elements ."

                                                                                        - "Important New Concepts in WPF "


7.2 Events


There are three types of routed events: direct, bubbling, and tunneling events.


Tunneling and bubbling work great for events that are built into every control, like mouse events; however, any event can tunnel or bubble.

To allow for both tunneling and bubbling, WPF supports attached events.

对 routing event 支持到了极致


Every event that uses the event system in WPF has a RoutedEvent field on the defining object, just like the Dependency-Property field that is used for the property system.

疑问, 这个方法好么?


7.3 Commands


简单点说, 就是一个通用的 Event Handler

Commands allow for a loose coupling between the UI and the behavior.


7.4 Triggers


Triggers are signaled by three things: (1) the state of a display property (Trigger), (2) the state of a data property (DataTrigger), or (3) an event (EventTrigger).


7.4.1 Adding Triggers to Data

Triggers can be used only inside of a template or style.

通过 Trigger 可以在绑定时做一些简单的检查, 设置属性工作, 从而赋予 XAML 一定的编程能力.

既然这样, 何不直接像 HTML, 引入 javascript 之类作为界面语言?


By using DataTrigger, we could move all the UI-dependent logic into the markup and leave the minimal amount of code in the code.


7.4.2 Adding Triggers to Controls


the design for Trigger and EventTrigger was inspired by the desire to have all view-dependent logic of a control declared in the markup.


7.4.3 Triggers as the New "if"


Triggers are a simple form of rules engine.




"Essential WPF - Chapter 6 Data" 阅读笔记

Chapter 6 Data 在 WPF 中, 数据绑定是一个核心的概念. 6.1 Data Principles Most applications are built to display or ...

"Essential WPF - Chapter 5 Visuals" 阅读笔记

(WPF 设计师讲述 WPF 框架设计思路的书, 非常不错. 之前看了一半, 一直想要看完, 刚好最近有项目界面决定采用 WPF, 捡起这本书, 继续学习) Chapter 5 Visuals WPF...


cocos2d-x学习笔记(7)--动作(Actions) 本文出自http://www.wenbanana.com稻草人博客,欢迎访问!        动作在cocos2d-x中可以说是精华...


  • 2015-06-10 13:58
  • 94KB
  • 下载

【移动开发】Essential Studio for WPF 2017 v1新版发布丨附下载

Essential Studio for WPF 2017 v1点击下载>>> Essential Studio for WPF更新至2017 v1版本,增加了数据网格、地图和sunburst ...

《CS:APP》 chapter 7 Linking 笔记


Programming HIVE Chapter 7-14 读书笔记

Chapter7 HiveQL : Views Hive不支持物化视图 a view will be shown using SHOW TABLES. 不可以把view作为insert或者lo...

Essential Studio for WPF更新至2017 v2,新增Adobe X安全性等功能丨附下载

Essential Studio for WPF是一个帮您轻松创建利于分析且高性能Windows应用程序的WPF界面控件。包含了如 grids、charts、gauges、menus、calendar...

Essential Diagram for WPF控件介绍及下载

Essential Diagram for WPF控件能够帮助你绘制强大的和功能丰富的图解,提供了直观地用户交互式的模型来创建和编辑图解,支持数据绑定,打印、序列化以及自动布局等。提供了多种图型对象,...