WPF初学者FAQ-笔记

近期看的一篇文章,记了点笔记。
1. 什么是WPF ?
我们已经有了 GDI,GDI+, DX,WPF 是啥?

看下面这个图:
 
从我自己的理解,WPF 是内部基于DX的一些封装,从 Windows Presentation Foundation的名字其实就
可以看出来。MS的东西总是让你上手很快,深入有点难度,精通得花很多时间。
再来看 WPF的一些说明:
WPF :- Microsoft almost had 3 to 4 API’s for display technologies , so why a need for one more display technology. DirectX had this excellent feature of using hardware acceleration. Microsoft wanted to develop UI elements like textboxes,button,grids etc using the DirectX technology by which they can exploit the hardware acceleration feature. As WPF stands on the top of directX you can not only build simple UI elements but also go one step further and develop special UI elements like Grid, FlowDocument, and Ellipse. Oh yes you can go one more step further and build animations.WPF is not meant for game development. DirectX still will lead in that scenario. In case you are looking for light animation ( not game programming ) WPF will be a choice. You can also express WPF using XML which is also called as XAML.In other words WPF is a wrapper which is built over DirectX. So let’s define WPF.
其实WPF就是DX的封装,让硬件加速可以用在展示(Presentation&UI)技术上,而不光光是游戏开发上。
WPF封装了很多界面控件,并且这种UI可以通过xml-xaml配置来动态的更改。
 
另一个重要的地方是 WPF 不能替代DX,它是封装了DX来替换现有.NET上的Form。
 
2. WPF的主要功能与架构
  • Has all equivalent common user controls like buttons, check boxes sliders etc.

  • Fixed and flow format documents

  • Has all of the capabilities of HTML and Flash

  • 2D and 3D vector graphics

  • Animation

  • Multimedia

  • Data binding

上面的无需多加解释。

high-level 架构图:

从上面的图来看,对于C++的Windows 程序员,练内功的,还是直接User32 + DX 来练习,快速开发则直接用WPF。一旦你的内功深厚,WPF游刃有余。

Milcore: – Mil stands for media integration library. This section is a unmanaged code because it acts like a bridge between WPF managed and DirectX / User32 unmanaged API.

这个就是个桥梁。主要是针对多媒体的。

Presentation core 是一些2D,3D 等计算几何的东西。

3. WPF 一些主要classes

这个就不copy了,看了下原文,然后对照自己的DUI 设计思路,感觉是有点相通啊:)
比如  Controls.Panel,  Controls.ItemsControl单独封装。

XAML 就不用说了。

So is XAML meant only for WPF?

No, XAML is not meant only for WPF. XAML is a XML-based language and it had various variants.

WPF XAML is used to describe WPF content, such as WPF objects, controls and documents. In WPF XAML we also have XPS XAML which defines an XML representation of electronic documents.

Silverlight XAML is a subset of WPF XAML meant for Silverlight applications. Silverlight is a cross-platform browser plug-in which helps us to create rich web content with 2-dimensional graphics, animation, and audio and video.

WWF XAML helps us to describe Windows Workflow Foundation content. WWF engine then uses this XAML and invokes workflow accordingly.

4. WPF XMAL 可以直接定义 Event 的bind

这个也无需多说,dynamic的 绑定,原理很简单,类似JS,但如果你自己想实现这个 动态event 绑定,还是需要花点时间的。最好研究下V8 源代码。

 

从上面的图来看,是不是和写Page 很像呢?

但XAML 一般情况下是 直接 编译成一个中间文件的。如果你想分离 code 和 xaml,动态解析xaml也是可以的,而且这也是 通用DUI的都需要支持的,换句话说,就是把 业务逻辑和 UI 分离开来。

其次是 在code 里能访问 xaml 里的 obj,xaml里可以call code 里的东西,并且这些都可以动态。

Page 里 JS 可以访问 document,window 一样。 这在自己设计DUI 也要考虑的一个问题,一般是嵌入脚本支持。

~Elliot @   2011-10-19

 

 

 

 

0

Comments are closed.