質問

Iを使用する必要の反射の結合価値を制御することが DataGridTemplateColumn (e.g HyperLinkButton).なんだろうけど、日本人にかかるのか?

そうでもないこと TextBlock のでは TextProperty 依存性がないのですがに拘束力のある表現から制御することなく直ちに TextProperty.こちらのコードを使用している取得の結合を表現する TextBlock:

FrameworkElement fe = (FrameworkElement)dependencyObj;
FieldInfo fi = fe.GetType().GetField("TextProperty");
BindingExpression bindingExpression = fe.GetBindingExpression((DependencyProperty)fi.GetValue(null))

ただし、以下のコードな作品の依存関係であるオブジェクト HyperLinkButton:

FieldInfo fi = fe.GetType().GetField("ContentProperty");

なんだろうけど、日本人どうかを手に入れることができる BindingExpression (結合)には、コンテンツの HyperLinkButton?

役に立ちましたか?

解決

みに加え、正しい結合フラグこうとするのだろうか。そのような場合inadaquate結合フラグが反射を生み出します。TextBlockは、テキストフィールドにTextBlock、HyperlinkButtonは、コンテンツから継承されたContentControl.

使ってみる静的-公共&FlattenedHierarchy結合フラグ:

FieldInfo fi = fe.GetType().GetField("ContentProperty", BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy);

追加のFlattenHierarchy反射結合フラグを教えるべきである反射を見出しのクラス階層を見ることpublic staticフィールドに代入します。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top