我有点不太清楚这些魔法。从我的理解来说,依赖属性是从DependencyObject继承的,因此值被存储在那里:
- in the instance itself if value is assigned (in the local dictionary)
or taken from the link to a parent element if value is not specified.
protected object GetValue(string propertyName) { if (LocalValues.ContainsKey(propertyName)) { return LocalValues[propertyName]; } return Parent.GetValue(propertyName); }
Am I correct in this?
Control.FontSizeProperty = TextElement.FontSizeProperty.AddOwner(
typeof(Control), new FrameworkPropertyMetadata(SystemFonts.MessageFontSize,
FrameworkPropertyMetadataOptions.Inherits));
AddOwner 方法调用附加属性时会将值分配给实例字段吗?这是何时发生的,值去哪里了?
谢谢!