首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用Silverlight 4应用主题

使用Silverlight 4应用主题
EN

Stack Overflow用户
提问于 2010-09-02 22:54:32
回答 1查看 2.2K关注 0票数 3

所以我已经尝试了一段时间让主题化在Silverlight4中工作。

我添加了一个对System.Windows.Controls.Theming.Toolkit和System.Windows.controls.Theming.ShinyRed的引用

然后我做了这样的事情:

代码语言:javascript
复制
<UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:dataInput="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data.Input" xmlns:WebbyDraw="clr-namespace:WebbyDraw" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"     x:Class="SilverlightApplication1.MainPage"
    Width="960" Height="700"  mc:Ignorable="d"
    xmlns:shinyRed="clr-namespace:System.Windows.Controls.Theming;assembly=System.Windows.Controls.Theming.ShinyRed" >
<shinyRed:ShinyRedTheme>
<Grid x:Name="LayoutRoot2">
....
</Grid>
</shinyRed:ShinyRedTheme>
</UserControl>

但是我总是得到相同的theme...no错误,但是什么也没有发生。我还尝试了Silverlight4工具包中的其他主题,并尝试将其应用于单个control...nothing...what我做错了吗?我已经读了几个教程,但还没有找到答案。

EN

回答 1

Stack Overflow用户

发布于 2012-10-08 23:49:37

这就是我如何使用主题,我也允许我的用户更改到他们喜欢的主题-

您可以用任何其他样式资源文件替换ShinyRed.xaml以支持多个主题,也可以通过编程方式完成(删除一个资源字典,然后添加另一个)。

在用户控件xmal中

代码语言:javascript
复制
xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit"
<toolkit:Theme x:Name="ThemeContainer">
 <Grid x:Name="LayoutRoot">
... all other controls in the page
</Grid>

复制shinyred主题所需的所有画笔和字体,并创建一个名为ShinyRed.xaml的单一样式文件(您只需遵循每个文件中的includes,即可将其全部放入一个文件中)

所以在您的App.xaml引用中,这个新创建的xaml就是它编译并运行!

代码语言:javascript
复制
<Application.Resources>
        <ResourceDictionary>

            <ResourceDictionary.MergedDictionaries>                
                <ResourceDictionary Source="Assets/ShinyRed.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Application.Resources>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/3628322

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档