2008-08-28 27 views
4

xamlでクラスの静的プロパティを参照するにはどうすればよいですか?言い換えれば、私はこのような何かをしたい:XAMLの静的フィールドへのアクセス

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

BASEDONでこれを行うための構文は何ですか?私はそれがある程度までStaticResourceを使用することを含むと仮定したが、私はそれが私のために働くことを得ていない。

答えて

11

使用私は `印象の下にあったx:Staticマークアップ拡張

<ResoureDictionary ... 
    xmlns:local="clr-namespace:Namespace.Where.Your.BaseThingy.Class.Is.Defined" 
> 
    <Style BasedOn="{x:Static local:BaseThingy.BaseStyle}" TargetType="BaseThingy" /> 
</ResourceDictionary> 
+1

{X:静的...}' Silverlightで動作しません。 –

+0

名前空間はどこですか。あなた.BaseThingy.Class.Is.Definedクラスの名前空間ですか? – Lance