【发布时间】:2010-11-11 09:31:42
【问题描述】:
我正在使用 Silverlight 4 并尝试分享一些常见的样式(颜色、画笔)。 我的做法是将它们放入“Common.xaml”资源字典,然后在所有其他资源字典中使用它。 像这样引用所有内容:
<Application
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="SampleApp.App"
>
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Assets/Styles/Common.xaml"/>
<ResourceDictionary Source="Assets/Styles/TextBoxStyle.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
问题是,我在 InitializeComponent 上收到一个异常,指出找不到常用样式(找不到具有名称/键的资源......)
我必须在我使用它的每个资源字典中明确引用“Common.xaml”......这基本上会导致“Common.xaml”中的每种颜色、画笔、模板和诸如此类的多个实例.
有没有办法共享资源,所以只能在 Silverlight 中实例化一次?
【问题讨论】:
标签: silverlight mergeddictionaries