Using a global ResourceDictionary in a UserControl Library

一笑奈何 提交于 2019-12-23 04:37:34

问题


I have have "Project A" with "MyResourceDictionary.xaml" in "App.xaml"

<Application.Resources>

    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="MyResourceDictionary.xaml"/>
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>

</Application.Resources>

I want to also use "MyResourceDictionary.xaml" in my user control library - "Project B"

Can I do this?

Thanks, Eamonn


回答1:


Check out the pack URI syntax. Something like:

<ResourceDictionary Source="ProjectB;component/MyResourceDictionary"/>



回答2:


@Kent Boogaart

Thanks for the help Kent, here is the working code

<UserControl.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="/ProjectA;component/MyResourceDictionary.xaml"/>
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</UserControl.Resources>

anyone else having trouble with this check out this link - http://msdn.microsoft.com/en-us/library/aa970069.aspx

Thanks, Eamonn



来源:https://stackoverflow.com/questions/5144435/using-a-global-resourcedictionary-in-a-usercontrol-library

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!