本主题包含有关 Windows Presentation Foundation (WPF) 版本 4.5 中的新增功能和增强功能的信息。
本主题包含以下各节:
用户界面虚拟化发生,当用户界面(UI)元素的子集从的数据项时根据哪些项目中生成出现在屏幕上。 VirtualizingPanel defines the IsVirtualizingWhenGrouping attached property that enables UI Virtualization for grouped data.‘ data-guid="35390e2daf6384f42f4669d4ba2207d3">VirtualizingPanel 定义启用分组的数据用户界面虚拟化的 IsVirtualizingWhenGrouping 附加属性。 有关分组的数据的更多信息,请参见如何:使用在XAML,的视图排序和组数据。 IsVirtualizingWhenGrouping attached property.‘ data-guid="0b053a1e26b56dfdacd0aca5062ae4f5">有关有效分组数据的更多信息,请参见中的 IsVirtualizingWhenGrouping 附加属性。
VirtualizingPanel, such as the VirtualizingStackPanel, displays partial items by using the ScrollUnit attached property.‘ data-guid="3a3854adec32858c393d0db0a73658aa">可以指定 VirtualizingPanel,例如 VirtualizingStackPanel,使用该 ScrollUnit 附加属性,是否显示分部项目。 ScrollUnit is set to Item, the VirtualizingPanel will only display items that are completely visible.‘ data-guid="0dbe076ebe401ae32822de751a5ead6b">如果 ScrollUnit 设置为 Item, VirtualizingPanel 将仅显示完全可见的项目。 ScrollUnit is set to Pixel, the VirtualizingPanel can display partially visible items.‘ data-guid="a0dd071d42188e2e9a171da122c13a07">如果 ScrollUnit 设置为 Pixel, VirtualizingPanel 可以显示部分可见项。
VirtualizingPanel is virtualizing by using the CacheLength attached property.‘ data-guid="a6bfc6502732cf93b7bfd4663d0c4999">使用该 CacheLength 附加属性时,,那么,当 VirtualizingPanel 有效可以指定缓存的范围在视区之前或之后。 缓存是空间量在或项目没有活动视区下面。 使用缓存避免生成UI元素,并滚动到视图可以提高性能。 缓存填充在较低优先级,以便应用程序不会无响应在操作中。 VirtualizingPanel.CacheLengthUnit property determines the unit of measurement that is used by VirtualizingPanel.CacheLength.‘ data-guid="afd110e3290f3c76ebf50f0194e9b577">VirtualizingPanel.CacheLengthUnit 属性确定 VirtualizingPanel.CacheLength使用的度量单位。
可以使用静态属性作为数据绑定源。 数据绑定引擎识别属性值更改时,如果静态引发事件。 SomeClass defines a static property called MyProperty, SomeClass can define a static event that is raised when the value of MyProperty changes.‘ data-guid="965b6c9b0d39bcb89256bd971ac28b02">例如,因此,如果选件类 SomeClass 定义名为 MyProperty的静态属性, SomeClass 可以定义引发的静态事件,当 MyProperty 的值发生更改时。 该静态事件可以使用以下签名之一。
public static event EventHandler MyPropertyChanged;
public static event EventHandler<PropertyChangedEventArgs> StaticPropertyChanged;
PropertyNameChanged that passes EventArgs to the event handler.‘ data-guid="650aaf4262bcc3d986b4d69b5e7005a7">请注意在第一种情况下,选件类公开通过 EventArgs 到事件处理程序命名 PropertyName的静态事件Changed 。 StaticPropertyChanged that passes PropertyChangedEventArgs to the event handler.‘ data-guid="a280f3c233237e1c8532183f84243ffb">在第二种情况下,选件类公开通过 PropertyChangedEventArgs 到事件处理程序命名 StaticPropertyChanged 的静态事件。 实现由静态属性使用任一方法,的选件类可以选择引发属性更改通知。
INotifyDataErrorInfo interface enables data entity classes to implement custom validation rules and expose validation results asynchronously.‘ data-guid="e8c71ede91d6701e996f5ebfd1b10126">INotifyDataErrorInfo 接口允许数据实体选件类实现自定义验证规则和显示验证结果异步。 此接口还支持自定义错误对象、多个错误每个属性,该属性错误和实体级错误。 INotifyDataErrorInfo.‘ data-guid="b28808d8bc098f2bdc5c14e4022c1064">有关更多信息,请参见INotifyDataErrorInfo。
Delay property to specify an amount of time to pass after the property changes on the target before the source updates.‘ data-guid="6500380f116b20c5eac46e64503fb1d8">如果您使用绑定到数据源的数据更新数据源,可以使用 Delay 属性指定时间通过,属性在目标将更新数据源之前之后。 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.‘ data-guid="d3bb248d206dbd57517f286b7c2499fe">例如,假设有其 Value 属性数据双向绑定到数据对象属性,并 UpdateSourceTrigger 属性设置为 PropertyChanged的有 Slider 。 Slider, the source updates for each pixel that the Slider moves.‘ data-guid="269121876f7817e50e19d98da12f1b61">在此示例中,那么,当用户移动 Slider, Slider 移动的每个像素的源更新。 ,仅当滑块的 Value 停止更改时,源对象通常需要滑块的值。 Delay to specify that the source should not be updated until a certain amount of time elapses after the thumb stops moving.‘ data-guid="8bed0dd4d77ccc7ddc72adf97bd989d6">若要防止太经常更新数据源,请使用 Delay 指定源不应更新,直到一段时间段,在滚动块停止移动后。
ICustomTypeProvider, also known as custom types.‘ data-guid="391ed3fa2038d1f2cbf4ec534039961d">WPF支持绑定到实现 ICustomTypeProvider对象的数据,也称为自定义类型。 可以在以下情况下使用自定义类型。
PropertyPath in a data binding.‘ data-guid="9c5c5b8eb8cbd9290c7c5785cbc5ac83">为数据绑定的 PropertyPath 。 Path property of a Binding can reference a property of a custom type.‘ data-guid="0cf5c22eda3e90925a2d0a275105daae">例如, Binding 的 Path 属性可以引用一个自定义类型的属性。
DataType property.‘ data-guid="f1f564bddc3124924a235dd05ff87cee">作为 DataType 属性的值。
DataGrid.‘ data-guid="22c6f380333a1c99c867ede5acc57a9b">为确定在 DataGrid的自动生成的列的类型。
BindingExpression of a Binding and need information about the source and target objects of the binding.‘ data-guid="40982b367db88dd46e2e32309df32ee2">在某些情况下,您可能会收到 Binding 和所需信息的 BindingExpression 有关绑定的源和目标对象。 新API添加允许您获取源或目标对象或该关联的属性。 BindingExpression, use the following APIs to get information about the target and source.‘ data-guid="806619287319daf42522386beb254474">当您具有 BindingExpression时,请使用有关目标与源的以下API获取信息。
查找绑定的该值 |
使用此API |
---|---|
目标对象 |
|
目标属性 |
|
源对象 |
|
源属性 |
|
BindingExpression belongs to a BindingGroup‘ data-guid="c7a37d4f3f16efeab91b520ef673d021">BindingExpression 是否属于 BindingGroup |
|
BindingGroup‘ data-guid="674d2e6689fd51feac293d3aae9d5950">BindingGroup 的所有者 |
DataContext of an item container in an ItemsControl becomes disconnected.‘ data-guid="82d2ade5f9dc39311c4e9c63b29405f5">有了项目容器 DataContext 在 ItemsControl 的断开连接的情况。 ItemsControl.‘ data-guid="af4839db8a5ab359b4bc561861ca89be">项容器是显示在 ItemsControl的项目的UI元素。 ItemsControl is data bound to a collection, an item container is generated for each item.‘ data-guid="4b01beb0ccfe8a53796caa14428ced4a">当 ItemsControl 的数据绑定到集合时,项容器为每个项目生成。 在某些情况下,项目容器从可视化树中移除。 ItemsControl.‘ data-guid="e85bd0e28c4e529c06f9489bd8e245f4">项目容器中移除的两个典型的情况是项目从基础集合中移除,并在虚拟化在 ItemsControl启用。 DataContext property of the item container will be set to the sentinel object that is returned by the BindingOperations.DisconnectedSource static property.‘ data-guid="abd1b460c8d86a298a3dec80745101f3">在这些情况下,项目容器的 DataContext 属性将设置为由 BindingOperations.DisconnectedSource 静态属性返回的sentinel。对象。 DataContext is equal to the DisconnectedSource object before accessing the DataContext of an item container.‘ data-guid="54815619d67a4761da62c1783d5c5ad4">您应检查 DataContext 是否与 DisconnectedSource 对象相同在访问项容器的 DataContext 之前。
可以将一个数据,排序或筛选。 ,当修改时, WPF 4.5使数据重新排列该数据。 DataGrid to list stocks in a stock market and the stocks are sorted by stock value.‘ data-guid="29161d04c24b60c79f87ad5cb4498168">例如,假设应用程序在一个股票上使用 DataGrid 股票列表,并股票由股票值排序。 活动对股票的 CollectionView有效,在 DataGrid 的股票的位置移动,则该股票的值大于另一个常用的值将成为大于还是小于。 ICollectionViewLiveShaping interface.‘ data-guid="f73168e69f8688bb8398d159d005f11c">有关更多信息,请参见 ICollectionViewLiveShaping 接口。
实现弱事件模式现在是更加容易,因为操作的用户可以参与,而不需要实现一额外的接口。 WeakEventManager class also enables subscribers to participate in the weak event pattern if a dedicated WeakEventManager does not exist for a certain event.‘ data-guid="7fb767b68fdf38cb9714016f65b369c1">,如果专用 WeakEventManager 为某个特定事件,不存在泛型 WeakEventManager 选件类还使用户能够参与弱事件模式。 Weak Event Patterns.‘ data-guid="9a968e5e0fcf247ae899f6ee4406c15a">有关更多信息,请参见弱事件模式。
计划程序选件类定义同步和异步操作的新方法。 Invoke method defines overloads that take an Action or Func<TResult> parameter.‘ data-guid="706a8a9cfcbd4cc8e49f522b6f9b7e8f">同步 Invoke 方法定义采用 Action 或 Func<TResult> 参数的重载。 InvokeAsync, also takes an Action or Func<TResult> as the callback parameter and returns a DispatcherOperation or DispatcherOperation<TResult>.‘ data-guid="85b6e0fcd595e57959ab1f5205e86caf">新的异步方法, InvokeAsync,也采用 Action 或 Func<TResult> 作为回调参数并返回 DispatcherOperation 或 DispatcherOperation<TResult>。 DispatcherOperation and DispatcherOperation<TResult> classes define a Task property.‘ data-guid="05171e248375ce3bb6e3f358a19458ae">DispatcherOperation 和 DispatcherOperation<TResult> 选件类定义一个 Task 属性。 InvokeAsync, you can use the await keyword with either the DispatcherOperation or the associated Task.‘ data-guid="b6f02a135fd71e44ca1440aabffbe21c">当您调用 InvokeAsync时,可以使用 DispatcherOperation 或关联的 Task的 await 关键字。 Task that is returned by a DispatcherOperation or DispatcherOperation<TResult>, call the DispatcherOperationWait extension method.‘ data-guid="4efc7973d453cdcfbebe903575bd4887">如果所 DispatcherOperation 或 DispatcherOperation<TResult>返回的需要同步等待 Task ,请调用 DispatcherOperationWait 扩展方法。 Task.Wait will result in a deadlock if the operation is queued on a calling thread.‘ data-guid="f15ed403a39080421533f293b6d8f7aa">;如果操作在调用线程,排队调用 Task.Wait 导致死锁。 Task to perform asynchronous operations, see Task Parallelism (Task Parallel Library).‘ data-guid="f1ce5f4a401b60af98bbcb1d66ac18e5">有关使用 Task 的更多信息执行异步操作,请参见 任务并行(任务并行库)。
WPF4.5 中的新增功能和增强功能的信息,布布扣,bubuko.com
原文:http://www.cnblogs.com/dotfun/p/3605725.html