質問

xaml でクラスの静的プロパティを参照するにはどうすればよいでしょうか?言い換えれば、次のようなことをしたいのです。

Class BaseThingy {
  public static readonly Style BaseStyle;
  ...
}
<ResoureDictionary ...>
  <Style BasedOn="BaseThingy.Style" TargetType="BaseThingy" />
</ResourceDictionary>

BasedOn でこれを行うための構文は何ですか?を使用する必要があると思いました StaticResource ある程度はできましたが、私にはうまくいきませんでした。

役に立ちましたか?

解決

使用 x:静的 マークアップ拡張子

<ResoureDictionary ...
  xmlns:local="clr-namespace:Namespace.Where.Your.BaseThingy.Class.Is.Defined"
>
  <Style BasedOn="{x:Static local:BaseThingy.BaseStyle}" TargetType="BaseThingy" />
</ResourceDictionary>
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top