你怎么去引用一个类的静态性在xaml?换句话说,我想要做这样的事情:

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

什么是语法要做到这一点,在基于?我认为这将涉及使用 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