且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

设置用户控件的样式

更新时间:2023-02-20 18:10:56

就我所见,这应该工作正常.您是否收到任何特殊警告或错误,或者样式中的某些部分没有得到应用?

That should be working fine as far as I can see. Do you get any special warnings or errors or do some parts from the Style not get applied?

要在设置Resources后设置样式,可以使用以下语法

To set the Style after Resources has been set, you can use the following syntax

<UserControl.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="/MainProject;component/Themes/MyTheme.xaml"/>
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</UserControl.Resources>
<UserControl.Style>
    <DynamicResource ResourceKey="UserControlStyle"/>
</UserControl.Style>

如果您在此之后仍然遇到问题,您可以将其与我在此处上传的示例应用程序进行比较:http://www.mediafire.com/?q1v98huubzw02zb

If you're still having problems after this you can compare it to my sample app which I uploaded here: http://www.mediafire.com/?q1v98huubzw02zb