Silverlight 4.0 使用Silverlight 4应用主题

Silverlight 4.0 使用Silverlight 4应用主题,silverlight-4.0,themes,Silverlight 4.0,Themes,所以我一直在努力让主题在Silverlight 4中工作 我添加了对System.Windows.Controls.Theming.Toolkit和System.Windows.Controls.Theming.ShinyRed的引用 然后我去做了这样的事情: <UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com

所以我一直在努力让主题在Silverlight 4中工作

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

然后我去做了这样的事情:

<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>

....

但我总是得到相同的旧主题…没有错误,但也没有发生任何事情。我还尝试了Silverlight 4工具包中的其他主题,并尝试将其应用于单个控件……什么都没有……我做错了什么?我已经阅读了一些教程,还没有找到答案。

这就是我使用主题的方式,我还允许我的用户更改到他们喜欢的主题-
您可以用任何其他样式的资源文件替换ShinyRed.xaml以支持多个主题,也可以通过编程方式完成(删除一个资源字典,然后添加另一个)

在用户控件xmal中

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>
xmlns:toolkit=”http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit"
... 页面中的所有其他控件
复制shinyred主题所需的所有画笔和字体,并创建一个名为shinyred.xaml的单一样式文件(您只需按照每个文件中的includes操作,即可将其全部包含在一个文件中)

因此,在你的App.xaml中引用这个新创建的xaml adn,这就是它的编译和运行

<Application.Resources>
        <ResourceDictionary>

            <ResourceDictionary.MergedDictionaries>                
                <ResourceDictionary Source="Assets/ShinyRed.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Application.Resources>


您尝试过在app.xaml中添加资源字典吗?我尝试过在app.xaml中添加名称空间定义(xmlns:shinyRed=“”),但这就是我需要做的全部吗?这似乎不起作用。