本文介绍了动态访问基础对象的DependencyProperty的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要动态访问依赖项属性.我有一个名为DummyDockPanel的类,该类派生自DockPanel.我正在使用:
Hi,
I need to dynamically access a dependency property. I have a class called DummyDockPanel, which is derived from DockPanel. I''m using:
FieldInfo key = typeof(DummyDockPanel).GetField("Test", BindingFlags.Public | BindingFlags.Static);
将key设置为null.更改为:
Which sets key to null. When changed to:
FieldInfo key = typeof(DockPanel).GetField("Test", BindingFlags.Public | BindingFlags.Static);
;
它按预期工作. DummyDockPanel肯定继承了依赖项属性,而我对问题所在不知所措.我从网上发现的几乎所有信息都与价值继承有关,这无济于事.任何帮助将不胜感激.
;
It works as expected. The DummyDockPanel definitely inherits the dependency property and I''m at a loss as to what the problem is. Almost all of the info I''ve found from the net has been about value inheritance, which isn''t helpful. Any help would be greatly appreciated.
推荐答案
FieldInfo key =Type.GetType(DummyDockPanel).BaseType.GetField("DockProperty");
这篇关于动态访问基础对象的DependencyProperty的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!