开发者

Silverlight: Reference ResourceDictionaries in external DLL's

I currently have a few different solutions for various different Silverlight front ends, one of which contains another Silverlight project dedicated to style resources. As you can imagine I want to break that ou开发者_运维百科t into its own solution and reference it from the GUI solutions. In WPF you would reference the common styles dll and use the pack syntax to load the xaml resource files, however in Silverlight that syntax is not supported and it cant find the xaml files which have been referenced in App.xaml as resource dictionaries. Has anyone managed to achieve this?


Jeremy Likness wrote a great article on using a theme project. He also covers how to dynamically load themes. We used this technique in a couple of our Silverlight projects with great success.

I believe you need to merge your style solution as a merged dictionary in the App.xaml.

<Application.Resources>
<ResourceDictionary>
    <ResourceDictionary.MergedDictionaries>                                
        <ResourceDictionary Source="/MyApp.MyThemeProject;component/Theme.xaml"/>
    </ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>

Best Practices for Themes in Modular Silverlight Applications


I feel you should look into SL Themes instead. DLL is created per theme which you can easily use in multiple projects/modules. Here is the like to into video


Turns out there was a problem with one of the dictionaries, all sorted now though. Thanks for the input!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜