【发布时间】:2011-10-30 20:16:29
【问题描述】:
我正在使用Silverlight toolkit 为我的整个应用程序设置样式。现在我需要从特定部分中删除隐式样式,这样它就不会干扰该部分中的其他样式。
基本上我想做这样的事情:
<theme:BureauBlackTheme>
<StackPanel x:Name="LayoutRoot">
<StackPanel><!-- Use the standard Bureau Black theme here --></StackPanel>
<StackPanel><!-- I don't want any implicit styling on this section --></StackPanel>
</StackPanel>
</theme:BureauBlackTheme>
查看Silverlight工具包的源码,发现主题是通过合并资源字典来应用的:
...
// Load the theme
ResourceDictionary resources = null;
using (stream)
{
resources = ResourceParser.Parse(stream, true);
owner.MergedDictionaries.Add(resources);
}
...
主题文件包含一堆隐式样式的地方:
<!--ScrollBar-->
<Style TargetType="ScrollBar">
<Setter Property="MinWidth" Value="17" />
...
因此,我需要一种从特定部分中删除所有隐式样式的方法,但只能从该部分中删除。我需要这个的原因是因为这些样式会干扰第三方控件的样式(我认为这与precedence of the control styles 有关)。
这在 Silverlight 4 中可行吗?也欢迎解决方法。
提前致谢!
【问题讨论】:
标签: c# silverlight xaml styles silverlight-toolkit