【翻译】WPF4.5新特性(MSDN的翻译读不太懂)

我很在意WPF的发展,有人说微软不再维护WPF了,无所谓,随他去。

MSDN上有简体版:http://msdn.microsoft.com/zh-cn/library/vstudio/bb613588.aspx,但翻译的有点糟糕

英文原文地址:http://msdn.microsoft.com/library/vstudio/bb613588 

下面是我的翻译:

Ribbon Control:

WPF4.5包含Ribbon control;Ribbon control包含快速访问工具栏,系统菜单栏和标签页。

获取更多信息,请查看Ribbon Overview

显示大量分组数据性能提升:

当屏幕上需要呈现大量的分组数据时,UI可以进行界面虚拟化。

VirtualizingPanel类定义了IsVirtualizingWhenGrouping属性。

这个属性可以使UI在呈现分组数据时进行界面虚拟化。

如果你想了解分组数据的更多信息,

请看:“怎样用xaml为分组数据排序”(译注:这个MSDN上就没给出链接)

如果你想了解虚拟化呈现分组数据的的相关信息

请看:“IsVirtualizingWhenGrouping”扩展属性的相关内容

针对VirtualizingPanel的新特性

1.

你可以使用ScrollUnit附加属性来指定一个VirtualizingPanel(VirtualizingStackPanel)显示部分的数据项

如果ScrollUnit被设置为Item,VirtualizingPanel将只显示容器内的可见的数据项。

如果ScrollUnit被设置为Pixel,VirtualizingPanel将显示呈现在屏幕上的那一部分。(译注:这两句的内容有待验证)

2.

你可以使用CacheLength附加属性来指定VirtualizingPanel的缓存大小(呈现前和呈现后都可以指定)

这个缓存是VirtualizingPanel不适用虚拟化的方式呈现数据之前或之后的缓存空间

使用缓存是为了避免在用户滚动滚动条时呈现界面元素。以此提示用户滚动滚动条时界面的响应速度。

.NET在分配这个缓存时使用了一个较低的优先权。以免用户在操作系统时界面反应迟钝。

VirtualizingPanel.CacheLengthUnit属性标志这缓存大小的单位

绑定到静态属性

WPF支持绑定到静态属性,

数据绑定引擎监控静态属性,一旦静态属性的值发生改变,将会触发一个指定的事件

例如:

如果有一个类,取名叫做SomeClass;

它有一个静态属性,取名叫做MyProperty;

在这个类内部可以按如方式定义静态事件:

public static event EventHandler MyPropertyChanged;

当MyProperty的值改变时,这个事件将被触发。

注意:

第一:事件的名字必须为:[静态属性名]changed

第二:SomeClass类必须包含一个名为StaticPropertyChanged的事件(定义方式如下), 

public static event EventHandler<PropertyChangedEventArgs> StaticPropertyChanged;

在非UI线程访问集合

你可以在一个非UI线程中访问和修改UI线程中的集合数据。

这样你就可以使用后台线程从UI线程中接收数据。

当你使用另一个线程修改数据集合的时候,展现在用户界面上的数据也会被相应的修改。

验证数据正确性

你可以使用INotifyErrorInfo接口来给数据实体类定义验证规则,

这个接口会异步验证用户录入的信息,并把结果展现在界面上。

这个接口也支持自定义错误对象,在一个属性上定义多个验证逻辑,跨属性的验证逻辑(译注:一个属性的值导致另一个属性验证不通过)

还有实体层面的错误(译注:enty-level errors这一句不知道是什么意思)

要想了解更多信息,请看:http://msdn.microsoft.com/en-us/library/vstudio/system.componentmodel.inotifydataerrorinfo

延迟更新数据绑定的数据源

如果你使用数据绑定来更新数据源,那么你可以使用delay属性来指定多久之后,把数据的更改通知数据源。

例如:你有一个slider,它的值双向绑定到一个数据源,并且UpdateSourceTrigger属性被设置为PropertyChanged

这样当一个用户滑动这个slider的时候,slider滑块的位置每改变一个像素,数据源都要发生相应的更改。

其实,我们只需要在slider停止滑动的时候更新数据源就可以了。

为了避免数据源被频繁的更新,可以使用delay属性来解决这个问题(译注:这里是挺长的一句,懒得翻译了)。

绑定到实现了ICustomTypeProvider接口的类型

WPF支持绑定到ICustomTypeProvider的继承类型,

1.可以绑定到PropertyType类型的属性,例如,可以把Path属性可以绑定到一个自定义类型

2.可以绑定到一个DataType类型的属性

3.作为一个可以决定DataGrid中自动生成的列的属性

----------------------------------------------

还有一些特性没有翻译,下一篇再翻译吧

另外有一个专家唱衰WPF,地址看这里:http://www.infoq.com/articles/Win8-LOB-Options

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Microsoft's Windows Presentation Foundation (WPF) provides you with a development framework for building high-quality user experiences for the Windows operating system. It blends together rich content from a wide range of sources and allows you unparalleled access to the processing power of your Windows computer. Pro WPF 4.5 in C# provides a thorough, authoritative guide to how WPF really works. Packed with no-nonsense examples and practical advice you'll learn everything you need to know in order to use WPF in a professional setting. The book begins by building a firm foundation of elementary concepts, using your existing C# skills as a frame of reference, before moving on to discuss advanced concepts and demonstrate them in a hands-on way that emphasizes the time and effort savings that can be gained. What you’ll learn •Understand the fundamentals of WPF programming from XAML to controls and data flow. •Develop realistic application scenarios to see navigation, localization and deployment in action. •Explore the advanced user interface controls that WPF provides. •Learn to manage documents from within WPF: Text layout, printing, and document packaging are all covered. •Use graphics and multimedia to add punch to your applications Who this book is for This book is designed for developers encountering WPF for the first time in their professional lives. A working knowledge of C# and the basic architecture of .NET is helpful to follow the examples easily, but all concepts will be explained from the ground up. Table of Contents 01.Introducing WPF 02.XAML 03.Layout 04.Dependency Properties 05.Routed Events 06.Controls 07.The Application 08.Element Binding 09.Commands 10.Resources 11.Styles and Behaviors 12.Shapes, Brushes, and Transforms 13.Geometries and Drawings 14.Effects and Visuals 15.Animation Basics 16.Advanced Animation 17.Control Templates 18.Custom Elements 19.Data Binding 20.Formatting 21.Bound Data 22.Data Views 23.Lists, Trees, and Grids 24.Windows Pages and Navigation 25.Menus, Toolbars, and Ribbons 26. Sound and Video 27.3-D Drawing 28.Documents 29. Printing 30.Interacting with Windows Forms 31.Multithreading 32.The Add-in Model 33.ClickOnce Deployment ----------------------------------------------------------- Pro WPF 4th edition,喜欢的朋友请支持正版。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值