"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 5 Visuals" 阅读笔记

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

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

Chapter 6 Data 在 WPF 中, 数据绑定是一个核心的概念. 6.1 Data Principles Most applications are built to display or ...
  • lethwei
  • lethwei
  • 2011年01月20日 09:41
  • 386


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


  • 2015年06月10日 13:58
  • 95KB
  • 下载

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

《APUE》chapter 7 Process Environment 学习笔记(加上自己的代码)

Process  Environment Everything start here -- main Function int main(int argc ,char *argv []); We ...

读书笔记:Deep Learning [Ada-Computation&ML series]--chapter7.Regularization

part0.概述 1.正则化的作用:降低泛化误差而不是训练误差。 2.形式: 1)约束或者惩罚,被设计用来编码某些先验知识。 2)对简单模型表达一种通用的选择 3)其他形式的,比如ensem...
  • lebula
  • lebula
  • 2016年10月28日 12:04
  • 235

读书笔记:C++ primer 5th edition--chapter7.类

part1.基本用法 1.const 成员函数示例代码 string Sales_data::isbn (const Sales_data *const this){ return this->isb...
  • lebula
  • lebula
  • 2016年10月07日 00:04
  • 256
您举报文章:"Essential WPF - Chapter 7 Actions" 阅读笔记