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

原创 2011年01月20日 09:41:00

Chapter 6 Data


在 WPF 中, 数据绑定是一个核心的概念.


6.1 Data Principles


Most applications are built to display or create some type of data.


6.1.1 The .NET Data Model


A data model describes the contract between a source of data and the consumer of that data.

说的很玄乎, 但是在这里的意思比较简单, 指的 IEnumerable, Property 之类的数据访问接口


Because all of WPF’s data operations are based on the fundamental .NET data model, WPF controls can retrieve data from any CLR object.

这意味着 As long as data can be accessed through the CLR, it can be visualized in WPF.


6.1.2 Pervasive Binding


Binding works great as a way to keep two objects in sync, but it begins to have problems when the data types of these objects don’t match up perfectly.

Binding 是个比较好用的手段, 因此需要最大化的利用, "Full Exploitation"

To make binding truly pervasive in the framework, it was necessary to provide ways to transform data.


6.1.3 Data Transformation


WPF supports two main types of transformation: value conversion and data templates.


6.2 Resources


WPF 里面 Resources 用得还是很多的.


The lookup path for resources:

1. Element hierarchy

2. Application.Resources
3. Type theme
4. System theme


6.3 Binding Basics


Binding is simply keeping two data points in sync with each other.


Data point is an abstract concept, the idea of a single “node” of data.

A data point can be described in a variety of ways; generally it is a data source and query. For example, a property data point would be an object and a property name. The property name determines the property on the source object from which data should be retrieved.


There are two base mechanisms for value conversion: TypeConverter, which is a base mechanism that has been in .NET since version 1.0; and the new IValueConverter.


Data points and transformation are the two fundamental constructs of binding.


6.4 Binding to CLR Objects


The property name identifier for object binding has two forms: one for simple CLR properties and another for WPF’s DependencyProperty-based properties.


This optimization is useful for two reasons: first, to avoid the performance impact of using reflection; and second, to enable binding to attached properties.


6.4.1 Editing


It is important for
data sources to provide change notification to allow the binding system to respond when the data is modified.


To enable our Person object model to support change notification, we have three options: (1) implement  INotifyPropertyChanged, (2) add events that report changes to properties, or (3) create Dependency-Property-based properties.


6.5 Binding to XML



6.6 Data Templates


data templates allow us to define how a piece of data will appear.


6.6.1 Template Selection



6.7 Advanced Binding


6.7.1 Hierarchical Binding


HierarchicalDataTemplate 递归绑定树形数据结构的方式比较值得关注


6.7.2 Collection Views



6.8 Data-Driven Display


One of the more powerful things we can do with WPF is to reverse the typical relationship: The data can be the center of an application, and the UI can be secondary.

听起来很好, 不过太极端了, 可能对某些特定场合有用, 但为此增加 WPF 的复杂度值得吗?


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

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

《APUE》chapter 6 System Data files and information 学习笔记(加上自己的代码)

System Data files and information

Graph Databases—Chapter 3 Graphs and Connected Data阅读笔记

本章内容: 着重讲述聚合存储(Key-Value,Documents, Bigtable)以及RDBMS(关系型数据库)在处理互有联系数据时查询延时高、开发成本高以及维护困难等缺点。从而...

Graph Databases—Chapter 4 Working with Graph Data阅读笔记

本章内容: 着重讲述图数据库模型设计的原则、Neo4j的语言Cypher、建立数据库注意事项等。本章的内容对于入门图数据库很重要,为以后使用图数据库打下良好的基础。...

PICMIG3.0 ATCA chapter 6 data transport

  • 2010年12月22日 11:36
  • 1.29MB
  • 下载

Chapter6 SQL:Data Manipulation

Chapter6 SQL:Data Manipulation Through this and the next two chapters,we use the following extended...

Chapter6. Data structure


Data Structures and Other Objects Using C++ (Chapter 1) 学习笔记二

Preconditions and Postconditions(先决条件和后置条件)     When you are using a function, you only need to thin...

Chapter 17 Core Data iOS 8 -Swift Programming cookBook 读书笔记

概述 以下是需要明白的概念: Persistent store: 固态存储,表示存储在Nand flash的真实数据库,我们不会之间用这个对象 Persistent store coordina...
您举报文章:"Essential WPF - Chapter 6 Data" 阅读笔记