所以我已经尝试了一段时间让主题化在Silverlight4中工作。
我添加了一个对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>但是我总是得到相同的theme...no错误,但是什么也没有发生。我还尝试了Silverlight4工具包中的其他主题,并尝试将其应用于单个control...nothing...what我做错了吗?我已经读了几个教程,但还没有找到答案。
发布于 2012-10-08 23:49:37
这就是我如何使用主题,我也允许我的用户更改到他们喜欢的主题-
您可以用任何其他样式资源文件替换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>复制shinyred主题所需的所有画笔和字体,并创建一个名为ShinyRed.xaml的单一样式文件(您只需遵循每个文件中的includes,即可将其全部放入一个文件中)
所以在您的App.xaml引用中,这个新创建的xaml就是它编译并运行!
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Assets/ShinyRed.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>https://stackoverflow.com/questions/3628322
复制相似问题