ResourceDictionary

5 posts, 0 answers
  1. Todor
    Todor avatar
    10 posts
    Member since:
    Aug 2008

    Posted 17 Feb 2009 Link to this post

    Hello,

    Can you give me an example how to use the ResourceDictionary you provide in order to mimic the WPF behaviour of MergedDictionaries, because I get an ERROR that the MergedDictionaries property is already set and my controls don't get their templates loaded.
  2. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 18 Feb 2009 Link to this post

    Hello Todor,

    Here is the syntax of the Telerik Resource dictionary:

    <telerik:ResourceDictionary Source="[uri to a xaml file, containing standard ResourceDictionary]" Keys="[comma separated list of all keys that should be copied from the Source]" />

    To apply a Telerik ResourceDictionary you need to do one of the two options below:
    1) Set the attached property telerik:ResourceDictionary.MergedDictionaries on a ResourceDictionary:
    <ResourceDictionary xmlns=... xmlns:x=... xmlns:telerik=...>
        <telerik:ResourceDictionary.MergedDictionaries>
            <telerik:ResourceDictionary Source="..." Keys="..." />
            <telerik:ResourceDictionary Source="..." Keys="..." />
            <telerik:ResourceDictionary Source="..." Keys="..." />
        <telerik:ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>

    2) Set the attached property on a FrameworkElement to merge the source dictionary with the Resources property of the target element:
    <StackPanel>
        <telerik:ResourceDictionary.MergedDictionaries>
            <telerik:ResourceDictionary Source="..." Keys="..." />
            <telerik:ResourceDictionary Source="..." Keys="..." />
            <telerik:ResourceDictionary Source="..." Keys="..." />
        <telerik:ResourceDictionary.MergedDictionaries>
    </StackPanel>

    Note that the source resources will not overwrite the target resources with the same keys, and also visual studio and blend show errors when the attached property is set multiple times, but there are no problems in runtime.

    Sincerely yours,
    Valeri Hristov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. Todor
    Todor avatar
    10 posts
    Member since:
    Aug 2008

    Posted 18 Feb 2009 Link to this post

    Thanks Valeri, works like a charm :)
  4. Cheng Lim Sek
    Cheng Lim Sek avatar
    33 posts
    Member since:
    Oct 2009

    Posted 12 Nov 2009 Link to this post

    Hi

    Setting the attached property telerik:ResourceDictionary.MergedDictionaries on a ResourceDictionary like you mention is not working in the Q3.
    When I try to write telerik:ResourceDictionary, I cannot find the ResourceDictionary property.
    I search through the Object Browser on the Telerik.Window.Controls, it do not have the ResourceDictionary in the libraries.

    Am I missing anything or the Q3 have remove this property. How can I solve this if I want to do something like this:
    <ResourceDictionary xmlns=... xmlns:x=... xmlns:telerik=...>
        <telerik:ResourceDictionary.MergedDictionaries>
            <telerik:ResourceDictionary Source="..." Keys="..." />
            <telerik:ResourceDictionary Source="..." Keys="..." />
            <telerik:ResourceDictionary Source="..." Keys="..." />
        <telerik:ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
  5. Hristo
    Admin
    Hristo avatar
    832 posts

    Posted 12 Nov 2009 Link to this post

    Hi Cheng Lim Sek,

    Just remove the telerik: and Keys="...".
    Silverlight 3 supports MergedDictionaries so there is no need to use Telerik.MergedDictionaries anymore. They were marked as obsolete in Q2 (or Q2.SP1).

    Kind regards,
    Hristo
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top