2009-09-18 78 views

回答

10

這不叫CSS,但你可以創建一個資源字典在這樣一個單獨的文件:

<ResourceDictionary 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> 

    <Style x:Key="MyStyledButton" TargetType="Button"> 
     . 
     Put the details of your style here, just like you would for a normal style. 
     . 
    </Style> 

</ResourceDictionary> 

然後你可以導入資源字典到其他XAML文件通過類設置的資源,例如,如果你有一個窗口類,你會怎麼做:

<Window.Resources> 
    <ResourceDictionary Source="MyStylesFile.xaml" /> 
</Window.Resources> 

現在的風格花費就好像你已經在窗口直接資源指定的樣式的窗口內的任何控制效果。

+1

非常感謝! – den123 2009-09-18 10:07:52