How to apply Application wide resource dictionary inside a custom control?

2 posts, 0 answers
  1. Syed Danish
    Syed Danish avatar
    70 posts
    Member since:
    Dec 2009

    Posted 21 Jun 2010 Link to this post

    I have resource dictionary declaration inside a Usercontrol like this:

            <ResourceDictionary Source="/Phoenix.CAG;Component/Themes/Black.xaml"/>

    I want to put the resource dictionary only in the App.xaml and let it apply in this usercontrol. Right now I also have this declared inside my app.xaml as

            <ResourceDictionary Source="/Phoenix.CAG;Component/Themes/Black.xaml"/>

     Is there any way to stop repeating the use of the same resource dictionary name in multiple places and put them only in one location and make it work?

    Can you please let me know how can I do that?

    Syed Aalam
  2. Dani
    Dani avatar
    848 posts

    Posted 23 Jun 2010 Link to this post

    Hi Syed Danish,

    From what  I see you are referencing a resource dictionary in a different assemly.

    I would suggest that you create a separate Silverlight Class Library which contains a single ResourceDictionary file and then reference this from all other projects that are part of your solution.

    Add a reference to the newly created ResourceDictionary as a MergedResourceDictionary in the App.xaml file in each of your projects. For example:

                    <ResourceDictionary Source="/MyTheme;component/Generic.xaml" />                 

    where Generic.xaml is the new ResourceDictionary.

    Styles from Generic.xaml will be applied to all UserControls residing in the projects which reference the custom class library.

    I hope this will help you achieve your goal. Please, write back in case you need further help.

    Best wishes,
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top