WPF中如何选择合适的元数据标记?(英文)
FrameworkPropertyMetadataOptions Enumeration:
Specifies the types of framework-level property behavior that pertain to a particular dependency property in the Windows Presentation Foundation (WPF) property system.
Member name | Description | |
---|---|---|
None | No options are specified; the dependency property uses the default behavior of the Windows Presentation Foundation (WPF) property system. | |
AffectsMeasure | The measure pass of layout compositions is affected by value changes to this dependency property. | |
AffectsArrange | The arrange pass of layout composition is affected by value changes to this dependency property. | |
AffectsParentMeasure | The measure pass on the parent element is affected by value changes to this dependency property. | |
AffectsParentArrange | The arrange pass on the parent element is affected by value changes to this dependency property. | |
AffectsRender | Some aspect of rendering or layout composition (other than measure or arrange) is affected by value changes to this dependency property. | |
Inherits | The values of this dependency property are inherited by child elements. | |
OverridesInheritanceBehavior | The values of this dependency property span separated trees for purposes of property value inheritance. | |
NotDataBindable | Data binding to this dependency property is not allowed. | |
BindsTwoWayByDefault | The BindingMode for data bindings on this dependency property defaults to TwoWay. | |
Journal | The values of this dependency property should be saved or restored by journaling processes, or when navigating by Uniform resource identifiers (URIs). | |
SubPropertiesDoNotAffectRender | The subproperties on the value of this dependency property do not affect any aspect of rendering. |
Setting Appropriate Metadata Flags
If your property (and value changes to it) affects the user interface (UI), and in particular affects how the layout system should size or render your element in a page, set one or more of the following flags: AffectsMeasure, AffectsArrange, AffectsRender.
AffectsMeasure indicates that a change to this property requires a change to UI rendering where the containing object might require more or less space within the parent. For example, a "Width" property should have this flag set.
AffectsArrange indicates that a change to this property requires a change to UI rendering that typically does not require a change in the dedicated space, but does indicate that the positioning within the space has changed. For example, an "Alignment" property should have this flag set.
AffectsRender indicates that some other change has occurred that will not affect layout and measure, but does require another render. An example would be a property that changes a color of an existing element, such as "Background".
These flags are often used as a protocol in metadata for your own override implementations of property system or layout callbacks. For instance, you might have an OnPropertyChanged callback that will call InvalidateArrange if any property of the instance reports a value change and has AffectsArrange as true in its metadata.
Some properties may affect the rendering characteristics of the containing parent element, in ways above and beyond the changes in required size mentioned above. An example is the MinOrphanLines property used in the flow document model, where changes to that property can change the overall rendering of the flow document that contains the paragraph. Use AffectsParentArrange or AffectsParentMeasure to identify similar cases in your own properties.
By default, dependency properties support data binding. You can deliberately disable data binding, for cases where there is no realistic scenario for data binding, or where performance in data binding for a large object is recognized as a problem.
By default, data binding Mode for dependency properties defaults to OneWay. You can always change the binding to be TwoWay per binding instance; for details, see How to: Specify the Direction of the Binding. But as the dependency property author, you can choose to make the property use TwoWay binding mode by default. Examples in existing dependency properties include ; the scenario for this property is that the IsSubmenuOpen setting logic and the compositing of MenuItem interact with the default theme style. The IsSubmenuOpen property logic uses data binding natively to maintain the state of the property in accordance to other state properties and method calls. Another example property that binds TwoWay by default is TextBox.Text.
You can also enable property inheritance in a custom dependency property by setting the Inherits flag. Property inheritance is useful for a scenario where parent elements and child elements have a property in common, and it makes sense for the child elements to have that particular property value set to the same value as the parent set it. An example inheritable property is DataContext, which is used for binding operations to enable the important master-detail scenario for data presentation. By making DataContext inheritable, any child elements inherit that data context also. Because of property value inheritance, you can specify a data context at the page or application root, and do not need to respecify it for bindings in all possible child elements. DataContext is also a good example to illustrate that inheritance overrides the default value, but it can always be set locally on any particular child element; for details, see How to: Use the Master-Detail Pattern with Hierarchical Data. Property value inheritance does have a possible performance cost, and thus should be used sparingly; for details, see Property Value Inheritance.
Set the Journal flag to indicate if your dependency property should be detected or used by navigation journaling services. An example is the SelectedIndex property; any item selected in a selection control should be persisted when the journaling history is navigated.
暂时摘抄于此,有空细述。
WPF中如何选择合适的元数据标记?(英文)的更多相关文章
- wpf中xaml的类型转换器与标记扩展
原文:wpf中xaml的类型转换器与标记扩展 这篇来讲wpf控件属性的类型转换器 类型转换器 类型转换器在asp.net控件中已经有使用过了,由于wpf的界面是可以由xaml组成的,所以标签的便利也需 ...
- Oracle数据库中如何选择合适的索引类型 .
索引就好象一本字典的目录.凭借字典的目录,我们可以非常迅速的找到我们所需要的条目.数据库也是如此.凭借Oracle数据库的索引,相关语句可以迅速的定位记录的位置,而不必去定位整个表. 虽然说,在表中是 ...
- MySQL中如何选择合适的备份策略和备份工具
数据库备份的重要性毋庸置疑,可以说,它是数据安全的最后一道防线.鉴于此,对于备份,我们通常会做以下要求: 多地部署 对于核心数据库,我们通常有两地三中心的部署要求.对于备份来说,也是如此. 一个备份 ...
- WPF中模板选择和DataContext的一些使用
如图样: View结构 MainView(MainViewModel)|---Guide1View(Guide1ViewModel)|---Guide2View(Guide2ViewModel) |- ...
- WPF中,Grid与Table的区别(英文)-转载
原文地址:http://blog.csdn.net/johnsuna/article/details/1742799 How is Grid Different from Table?Table an ...
- 在WPF中使用文件夹选择对话框
开发中有时会想实现"选择某个文件夹"的效果: 在WPF中,使用Microsoft.Win32.OpenFileDialog只能选择文件,FolderBrowserDialog只能用 ...
- 谈谈数据库中MyISAM与InnoDB区别 针对业务类型选择合适的表
MyISAM:这个是默认类型,它是基于传统的ISAM类型, ISAM是Indexed Sequential Access Method (有索引的顺序访问方法) 的缩写,它是存储记录和文件的标准方法. ...
- 在WPF中自定义控件
一, 不一定需要自定义控件在使用WPF以前,动辄使用自定义控件几乎成了惯性思维,比如需要一个带图片的按钮,但在WPF中此类任务却不需要如此大费周章,因为控件可以嵌套使用以及可以为控件外观打造一套新的样 ...
- WPF中的数据绑定!!!
引用自:https://msdn.microsoft.com/zh-cn/magazine/cc163299.aspx 数据点: WPF 中的数据绑定 数据点 WPF 中的数据绑定 John Pap ...
随机推荐
- Visual Studio中你所不知道的智能感知
在Visual Studio中的智能感知,相信大家都用过.summary,param,returns这几个相信很多人都用过的吧.那么field,value等等这些呢. 首先在Visual Studio ...
- complex query几个原则
1.一般来说in比exists更有利(更容易变成join). 2.尽量避免union,使用union all代替,避免sort. 3,绝对不能在没有on条件下使用join(除非有特殊目的). 4.ou ...
- VC使用ADO连接远程oracle数据库
_ConnectionPtr pConn;//连接对像 _RecordsetPtr pRect;//记录集对象 _CommandPtr pCmd;//命令对象 pRect.CreateInstanc ...
- Eclipse查看某个方法被哪些类调用
方法一:打开该类,在类的定义上即类名上,右键-->References--->Project ,就可以查看该类是否被工程中的其他Java文件引用过:但是如果在JSP页面,这个方法查不出来 ...
- hadoop集群中的日志文件 分类: A1_HADOOP 2015-02-28 20:37 680人阅读 评论(0) 收藏
hadoop存在多种日志文件,其中master上的日志文件记录全面信息,包括slave上的jobtracker与datanode也会将错误信息写到master中.而slave中的日志主要记录完成的ta ...
- 【心情】"支NMLGB配树”
大视野oj坏了 那就做杭电呗 看看大触都做杭电里的哪些题 看到杭电的分类了 Tarjan算法诶,我好像会嘛,就是你了 诶,怎么不是求强连通分量? 哦,原来是Tarjan算法的另外一个应用叫做支配树 我 ...
- 撸代码--类QQ聊天实现(基于linux 管道 信号 共享内存)
一:任务描写叙述 A,B两个进程通过管道通信,像曾经的互相聊天一样,然后A进程每次接收到的数据通过A1进程显示(一个新进程,用于显示A接收到的信息),A和A1间的数据传递採用共享内存,相应的有一个B1 ...
- 在SSMS查询分析器中显示行号
有网友问及,看到Insus.NET帮他解决问题分享的截屏时,发现代码中有显示行号.而他的没有. Step1: Go to Tools > Options Step2: In the Option ...
- Android5.0网络之ipv6
移动设备的大量兴起势必进一步加强ip地址不足的危机. ipv6或许成为一种比較好的选择方案. ipv6地址的获取分为两种方式:无状态:有状态 无状态:通过接收路由公告(RA)来设置自己的ipv6地址 ...
- 关于MD5值加密算法
public static string getMD5(string str)//该方法获取字符串的md5加密 通经常使用来验证数据 { System.Security.Cry ...