2009-09-18 84 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