mardi 7 février 2017

Setting a value of an attached property via Reflection

I am able to obtain a property called ShowKeyboardCuesProperty which is an attached dependency property present in KeyboardNavigation class. It is an internal static DP with no backing CLR property.

(typeof(KeyboardNavigation).GetMember("ShowKeyboardCuesProperty", MemberTypes.All, BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static)[0] as FieldInfo)

I need to set this attached property on another element whose reference I can get easily. Let's refer to that element as DependencyObject d.

How can I call d.SetValue() and set the above attached property(from FieldInfo) to true?

Or is there any other way I can achieve the same?





Aucun commentaire:

Enregistrer un commentaire