几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量  


返回   几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 » 仿射空间:CAX软件开发(三)二次开发与程序设计 » 程序设计 » vc编程
用户名
密码
注册 帮助 会员 日历 银行 搜索 今日新帖 标记论坛为已读


回复
 
主题工具 搜索本主题 显示模式
旧 2013-03-29, 09:42 AM   #1
huangyhg
超级版主
 
huangyhg的头像
 
注册日期: 04-03
帖子: 18592
精华: 36
现金: 249466 标准币
资产: 1080358888 标准币
huangyhg 向着好的方向发展
默认 Wpf 版本 4.5 的新增功能 ? 中英文对照

WPF 版本 4.5 的新增功能– 中英文对照

What's New in WPF Version 4.5 RC

.NET Framework 4.5

Other Versions

21 out of 27 rated this helpful - Rate this topic

This topic contains information about new and enhanced features in Windows Presentation Foundation (WPF) version 4.5.

This topic contains the following sections:

· Ribbon control

· Improved performance when displaying large sets of grouped data

· New features for the VirtualizingPanel

· Binding to static properties

· Accessing collections on non-UI Threads

· Synchronously and Asynchronously validating data

· Automatically updating the source of a data binding

· Binding to types that Implement ICustomTypeProvider

· Retrieving data binding information from a binding expression

· Checking for a valid DataContext object

· Repositioning data as the data's values change (Live shaping)

· Improved Support for Establishing a Weak Reference to an Event

· New methods for the Dispatcher class

· Markup Extensions for Events



WPF 版本 4.5 的新增功能

.NET Framework 4.5


本主题包含有关 Windows Presentation Foundation (WPF) 版本 4.5 中的新增功能和增强功能的信息。

本主题包含以下14节:


Ribbon control WPF 4.5 ships with a Ribbon control that hosts a Quick Access Toolbar, Application Menu, and tabs. For more information, see the Ribbon Overview.

1)新增Ribbon控件

WPF 4.5新增控件Ribbon:能快速访问工具栏、应用程序菜单和选项的Ribbon 控件。有关更多信息,请参见功能区概述

Improved performance when displaying large sets of grouped data
UI virtualization occurs when a subset of user interface (UI) elements are generated from a larger number of data items based on which items are visible on the screen. The VirtualizingPanel defines the IsVirtualizingWhenGrouping attached property that enables UI Virtualization for grouped data. For more information about grouping data, see How to: Sort and Group Data Using a View in XAML. For more information about virtualizing grouped data, see the IsVirtualizingWhenGrouping attached property.


2)当显示大数据项或大集合时,可设置虚拟分组以改善性能

用户界面(UI)设定虚拟分组的原则:
依据哪些子项需要在屏幕上可见的原则,可将大数据项拆分成由小数据构成的子集。(类似于dir/p/w分页显示文件?)

在VirtualizingPanel 新增IsVirtualizingWhenGrouping 附加属性。
IsVirtualizingWhenGrouping:是否开启分组数据的UI虚拟化功能。

有关分组的数据的更多信息,请参见如何在XAML中使用视图进行排序和分组数据。有关有效分组数据的更多信息,请参见IsVirtualizingWhenGrouping 附加属性。


New features for the VirtualizingPanel
  1. You can specify whether a VirtualizingPanel, such as the VirtualizingStackPanel, displays partial items by using the ScrollUnit attached property. If ScrollUnit is set to Item, the VirtualizingPanel will only display items that are completely visible. If ScrollUnit is set to Pixel, the VirtualizingPanel can display partially visible items.
  2. You can specify the size of the cache before and after the viewport when the VirtualizingPanel is virtualizing by using the CacheLength attached property. The cache is the amount of space above or below the viewport in which items are not virtualized. Using a cache to avoid generating UI elements as they’re scrolled into view can improve performance. The cache is populated at a lower priority so that the application does not become unresponsive during the operation. The VirtualizingPanel.CacheLengthUnit property determines the unit of measurement that is used by VirtualizingPanel.CacheLength.







3)VirtualizingPanel的新功能 – 是否显示分项和指定缓存长度


  1. VirtualizingPanel(比如VirtualizingStackPanel)新增ScrollUnit 附加属性,设置是否显示分项。如果ScrollUnit 设置为ItemVirtualizingPanel 将仅显示完全可见的项。如果ScrollUnit 设置为PixelVirtualizingPanel 显示部分可见项。
  2. VirtualizingPanel新增CacheLength 附加属性,指定在视区之前或之后的缓存范围。缓存是指在活动视图之上或之下不可见项所占的空间。当滚动视图时,使用缓存可避免生成UI数据以提高性能。但是为了避免应用程序没有响应,将以较低优先级填充缓存。VirtualizingPanel::CacheLengthUnit 缓存长度单位VirtualizingPanel::CacheLength缓存长度
Binding to static properties

You can use static properties as the source of a data binding. The data binding engine recognizes when the property's value changes if a static event is raised. For example, if the class SomeClass defines a static property called MyProperty, SomeClass can define a static event that is raised when the value of MyProperty changes. The static event can use either of the following signatures.

  • public static event EventHandler MyPropertyChanged;
  • public static event EventHandler<PropertyChangedEventArgs> StaticPropertyChanged;
Note that in the first case, the class exposes a static event named PropertyNameChanged that passes EventArgs to the event handler. In the second case, the class exposes a static event named StaticPropertyChanged that passes PropertyChangedEventArgs to the event handler. A class that implements the static property can choose to raise property-change notifications using either method.


4)绑定到静态属性 –当属性值被更改时,引发静态事件

使用静态属性作为数据绑定源,数据绑定引擎能识别静态属性值被更改而引发静态事件。例如,如果类SomeClass 定义名为 MyProperty的静态属性, SomeClass 还可以定义当 MyProperty 的值发生更改时,引发的静态事件。静态事件可使用下面的任意一种签名声明。

  • public static event EventHandler MyPropertyChanged;
  • public static event EventHandler<PropertyChangedEventArgs> StaticPropertyChanged;
请注意在第一种情况下,类使用静态事件PropertyNameChanged传递EventArgs 到事件处理程序。在第二种情况下,类使用静态事件StaticPropertyChanged 传递PropertyChangedEventArgs 到事件处理程序。
类可使用上述任何一种方式,引发属性更改通知。

Accessing collections on non-UI Threads

WPF enables you to access and modify data collections on threads other than the one that created the collection. This enables you to use a background thread to receive data from an external source, such as a database, and display the data on the UI thread. By using another thread to modify the collection, your user interface remains responsive to user interaction.


5)在非UI线程访问集合

WPF可使用一个线程访问和修改另外一个线程上的数据集。您可使用后台线程接收从外部源的数据(如数据库),并将此数据显示在用户界面线程上。使用另一个线程修改数据集,用户界面无需等待,可实时响应用户交互的要求。(问:在多线程且要求响应效率越快越好的应用程序中,比invoke效率高吗?耗内存吗?这个功能如何实现的?好奇中,看似很好用)


Synchronously and Asynchronously validating data

The INotifyDataErrorInfo interface enables data entity classes to implement custom validation rules and expose validation results asynchronously. This interface also supports custom error objects, multiple errors per property, cross-property errors, and entity-level errors. For more information, see INotifyDataErrorInfo.

6)同步和异步验证数据

INotifyDataErrorInfo 接口允许数据实体类执行自定义验证规则和异步导出验证结果。此接口还支持自定义错误对象,一个属性多个错误,跨属性错误和实体级错误。有关更多信息,请参见INotifyDataErrorInfo

Automatically updating the source of a data binding

If you use a data binding to update a data source, you can use the Delay property to specify an amount of time to pass after the property changes on the target before the source updates. For example, suppose that you have a Slider that has its Value property data two-way bound to a property of a data object and the UpdateSourceTrigger property is set to PropertyChanged. In this example, when the user moves the Slider, the source updates for each pixel that the Slider moves. The source object typically needs the value of the slider only when the slider's Value stops changing. To prevent updating the source too often, use Delay to specify that the source should not be updated until a certain amount of time elapses after the thumb stops moving.





7)自动更新数据绑定源-新增设定延迟时间更新数据源

如果您使用数据绑定更新数据源,可以使用Delay 属性设置延迟时间,在目标属性被更改之后,依据特定的延迟时间刷新数据源。例如,假设你有个滑动条Slider,将其Value属性双向绑定到数据对象属性,并将UpdateSourceTrigger 属性设置为PropertyChanged。在这个示例中,当用户移动Slider,数据源随着Slider 移动的每个像素不断更新。但是仅当滑块的Value 停止更改时,源对象才需要滑块的值。若要防止太频繁更新数据源,请使用Delay 指定特定的时间段,在滚动块停止移动后,才更新数据源。

(类似应用- 解决editbox文本框控件输入一个字符的响应事件的频繁触发)

Binding to types that Implement ICustomTypeProvider

WPF supports data binding to objects that implement ICustomTypeProvider, also known as custom types. You can use custom types in the following cases.
  1. As a PropertyPath in a data binding. For example, the Path property of a Binding can reference a property of a custom type.
  2. As the value of the DataType property.
  3. As a type that determines the automatically generated columns in a DataGrid.


8)绑定到实现ICustomTypeProvider的类型


WPF支持数据绑定到实现ICustomTypeProvider的对象,也称为自定义类型。可以在以下情况下使用自定义类型。
  1. 作为数据绑定的PropertyPath 。例如,BindingPath 属性可以引用一个自定义类型的属性。
  2. 作为DataType 属性的值。
3. 在DataGrid中自动生成的列的类型。

Retrieving data binding information from a binding expression

In certain cases, you might get the BindingExpression of a Binding and need information about the source and target objects of the binding. New APIs have been added to enable you to get the source or target object or the associated property. When you have a BindingExpression, use the following APIs to get information about the target and source.



To find this value of the binding
Use this API
The target object

BindingExpressionBase.Target

The target property

BindingExpressionBase.TargetProperty

The source object

BindingExpression.ResolvedSource

The source property

BindingExpression.ResolvedSourcePropertyName

Whether the BindingExpression belongs to a BindingGroup

BindingExpressionBase.BindingGroup

The owner of a BindingGroup

Owner


9)用约束表达式检索数据绑定信息


在某些情况下,您可能需要BindingBindingExpression 去获得绑定的源和目标对象的有关信息。新API提供获取源,目标对象或该关联的属性。当您有BindingExpression时,请使用目标与源的以下API获取有关信息。




查找绑定的该值

使用此API

目标对象

BindingExpressionBase::Target

目标属性

BindingExpressionBase::TargetProperty

源对象

BindingExpression::ResolvedSource

源属性

BindingExpression::ResolvedSourcePropertyName

BindingExpression 是否属于BindingGroup

BindingExpressionBase::BindingGroup

BindingGroup 的所有者

Owner


Checking for a valid DataContext object

There are cases where the DataContext of an item container in an ItemsControl becomes disconnected. An item container is the UI element that displays an item in an ItemsControl. When an ItemsControl is data bound to a collection, an item container is generated for each item. In some cases, item containers are removed from the visual tree. Two typical cases where an item container is removed are when an item is removed from the underlying collection and when virtualization is enabled on the ItemsControl. In these cases, the DataContext property of the item container will be set to the sentinel object that is returned by the BindingOperations.DisconnectedSource static property. You should check whether the DataContext is equal to the DisconnectedSource object before accessing the DataContext of an item container.

10)检查 DataContext对象的有效性


ItemsControl 断开连接时,须检查项容器的DataContext的有效性。项容器是显示在ItemsControl的项的UI元素。当ItemsControl 的数据绑定到集合时,每个项目生成相应的项容器。在某些情况下,项容器从可视化树中移除,一是项从基础集合中移除,二是在ItemsControl启用虚拟化。在这些情况下,项容器的DataContext 属性将被设置为由BindingOperations.DisconnectedSource 静态属性返回的sentinel对象。您在访问项容器的DataContext 之前,应检查DataContextDisconnectedSource 对象是否相同。


Repositioning data as the data's values change (Live shaping)

A collection of data can be grouped, sorted, or filtered. WPF 4.5 enables the data to be rearranged when the data is modified. For example, suppose that an application uses a DataGrid to list stocks in a stock market and the stocks are sorted by stock value. If live sorting is enabled on the stocks' CollectionView, a stock's position in the DataGrid moves when the value of the stock becomes greater or less than another stock's value. For more information, see the ICollectionViewLiveShaping interface.


11)当数据值被更改时重新定位数据 (Live建模)

当支持分组、排序或筛选的数据集被修改时,WPF 4.5能重新排列该数据集。例如,假设应用程序在一个股票市场中使用DataGrid 作为股票列表,且股票由股票值排序。如果股票的CollectionView正以实时排序,当此股票的值大于或小于另一个股票值时,也随之更改股票在DataGrid的相应位置。有关更多信息,请参见ICollectionViewLiveShaping 接口。


Improved Support for Establishing a Weak Reference to an Event

Implementing the weak event pattern is now easier because subscribers to events can participate in it without implementing an extra interface. The generic WeakEventManager class also enables subscribers to participate in the weak event pattern if a dedicated WeakEventManager does not exist for a certain event. For more information, see Weak Event Patterns.


12)改进事件的弱引用


现在更加容易实现弱事件模式,因为操作的用户可以参与其中,而不再需要实现额外的接口。对于某个特定事件来说,即使专用WeakEventManager 不存在,泛型WeakEventManager 类也提供用户能够参与弱事件模式。有关更多信息,请参见弱事件模式

New methods for the Dispatcher class

The Dispatcher class defines new methods for synchronous and asynchronous operations. The synchronous Invoke method defines overloads that take an Action or Func<TResult> parameter. The new asynchronous method, InvokeAsync, also takes an Action or Func<TResult> as the callback parameter and returns a DispatcherOperation or DispatcherOperation<TResult>. The DispatcherOperation and DispatcherOperation<TResult> classes define a Task property. When you call InvokeAsync, you can use the await keyword with either the DispatcherOperation or the associated Task. If you need to wait synchronously for the Task that is returned by a DispatcherOperation or DispatcherOperation<TResult>, call the DispatcherOperationWait extension method. Calling Task.Wait will result in a deadlock if the operation is queued on a calling thread. For more information about using a Task to perform asynchronous operations, see Task Parallelism (Task Parallel Library).



13)Dispatcher类的新方法 - 同步和异步操作


Dispatcher类定义了同步和异步操作的新方法。同步Invoke 方法重载了采用ActionFunc<TResult> 参数。新的异步方法InvokeAsync,也采用ActionFunc<TResult> 作为回调参数并返回DispatcherOperationDispatcherOperation<TResult>DispatcherOperationDispatcherOperation<TResult> 类还定义了Task 属性。当您调用InvokeAsync时,可以使用DispatcherOperation 或关联的Task的 await 关键字。如果需要同步等待由DispatcherOperationDispatcherOperation<TResult>返回的Task ,请调用DispatcherOperationWait 扩展方法。值得注意的是如果操作已在调用线程中排队,调用Task::Wait 将导致死锁。有关使用Task执行异步操作的更多信息,请参见任务并行(任务并行库)

Markup Extensions for Events

WPF 4.5 supports markup extensions for events. While WPF does not define a markup extension to be used for events, third parties are able to create a markup extension that can be used with events.



14)事件的标记扩展


WPF 4.5支持事件的标记扩展。当WPF没有定义事件的标记扩展,第三方可创建用于事件的标记扩展。

See Also

Concepts

What's New in the .NET Framework 4.5

请参见


概念

.NET Framework 4.5 中的新增功能

__________________
借用达朗贝尔的名言:前进吧,你会得到信心!
[url="http://www.dimcax.com"]几何尺寸与公差标准[/url]

此帖于 2013-03-30 10:21 AM 被 huangyhg 编辑.
huangyhg离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
旧 2013-03-30, 10:07 AM   #2
huangyhg
超级版主
 
huangyhg的头像
 
注册日期: 04-03
帖子: 18592
精华: 36
现金: 249466 标准币
资产: 1080358888 标准币
huangyhg 向着好的方向发展
默认 回复: Wpf 版本 4.5 的新增功能 ? 中英文对照

翻译好久没练,效率低下......
中文版分享链接
http://dimcax.com/3dimcad/WPF4.5.html
http://dimcax.com/3dimcad/WPF4.5.html
__________________
借用达朗贝尔的名言:前进吧,你会得到信心!
[url="http://www.dimcax.com"]几何尺寸与公差标准[/url]

此帖于 2013-03-30 10:38 AM 被 huangyhg 编辑.
huangyhg离线中   回复时引用此帖
回复


主题工具 搜索本主题
搜索本主题:

高级搜索
显示模式

发帖规则
不可以发表新主题
不可以回复主题
不可以上传附件
不可以编辑您的帖子

vB 代码开启
[IMG]代码开启
HTML代码关闭

相似的主题
主题 主题发起者 论坛 回复 最后发表
【转帖】wpf多线程的一种解决方案 huangyhg C# 0 2011-07-05 09:12 PM
【转帖】wpf线程处理模型 huangyhg C# 0 2011-07-05 08:53 PM


所有的时间均为北京时间。 现在的时间是 07:30 PM.


于2004年创办,几何尺寸与公差论坛"致力于产品几何量公差标准GD&T | GPS研究/CAD设计/CAM加工/CMM测量"。免责声明:论坛严禁发布色情反动言论及有关违反国家法律法规内容!情节严重者提供其IP,并配合相关部门进行严厉查处,若內容有涉及侵权,请立即联系我们QQ:44671734。注:此论坛须管理员验证方可发帖。
沪ICP备06057009号-2
更多