财产价值继承 [英] Property Value Inheritance

查看:53
本文介绍了财产价值继承的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在MSDN和其他资源上进行了大量搜索之后,我基本上发现某些依赖属性确实支持类似于WPF的属性值继承。但是,据我所知,没有确定哪些属性可以定义哪些属性的明确列表。例如,我知道字体属性;但是Horizo​​ntalContentAlignment却没有。我还在该论坛中看到了另一个线程,该线程指出DP优先级列表不包括值继承( http://msdn.microsoft.com/en-us/library/cc265148(VS.95).aspx#listing )。

After much searching on MSDN and other sources I have basically found that "some" Dependancy Properties do indeed support property value inheritance similar to WPF. However, as far as I can tell, there is no definitive list of which properties do, and which do not. I know Font properties, for example, do; yet HorizontalContentAlignment does not. I have also seen the other thread in this forum which points out that the DP Precedence list does not include value inheritance (http://msdn.microsoft.com/en-us/library/cc265148(VS.95).aspx#listing).

此外,似乎甚至无法将可继承元数据应用于任何自定义DP,因此似乎silverlight框架已针对特定属性对其进行了自定义修改。我需要确切地知道哪些依赖属性确实支持属性值继承。如果我错过了关于该主题或主题的明显文章,那么我表示歉意,但是我在搜索中已经非常彻底了。

Furthermore, it seems that it is not possible to even apply Inheritable metadata to any custom DP, so it seems the silverlight framework has custom hacked it in for specific properties. I need to know exactly which dependancy properties do indeed support property value inheritance. If I have missed an obvious article on this, or a thread, then I apologize but I have been pretty thorough in my search.

谢谢。

推荐答案

您提到Font属性支持此功能,所以我在反射器中做了一些挖掘,发现这很有趣:

You mention that the Font properties support this so I did a little digging in reflector and found this interesting:

TextBlock

TextBlock

public static readonly DependencyProperty FontSizeProperty = DependencyProperty.RegisterCoreProperty(0x40003714, typeof(double));

Control

public static readonly DependencyProperty FontSizeProperty = DependencyProperty.RegisterCoreProperty(0x80003714, typeof(double));

内联

public static readonly DependencyProperty FontSizeProperty = DependencyProperty.RegisterCoreProperty(0x3714, typeof(double));

所以所有这三个类都定义了FontSizeProperty,并且使用的id看起来非常相似,就好像第一位只是某种标志。因此,也许在幕后进行了一些事情,这些事情允许您所谓的属性继承,因为框架可能会在这些类似的dp id之间传递值。

So all three of those classes define a FontSizeProperty and the id used look very similar as if that first bit is just a flag of some kind. So perhaps there is something going on under the covers that allows what you're calling property inheritance since the the framework might transfer the values between these similar dp ids.

这篇关于财产价值继承的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆