Allow Merged Dictionaries hierarchically merging

MakemanMakeman BYMember
edited November 2017 in Xamarin.Forms

[Sorry for links format, I have not permission to post correct links...]
[Moved from "" by suggestion of Paul DiPietro]


WPF and UWP allow to merge dictionaries hierarchically. It is very useful feature which helps to split resources by different logically files.
Current Xamarin.Forms implementation of Merged Dictionaries at master brunch can not merge dictionaries hierarchically.

Just try to run following method on master and WPF or UWP for tests.

    public static void MergedDictionariesDeepSublevels()
        var rd0 = new ResourceDictionary();
        var rd1 = new ResourceDictionary { { "Key1", "Level1" } };
        var rd2 = new ResourceDictionary { { "Key2", "Level2" } };


        Assert.That(rd0["Key1"], "Level1");
        Assert.That(rd0["Key2"], "Level2"); // <= fail on master, work on WPF or UWP

        //Assert.That(rd0.ContainsKey("Key1"), Is.EqualTo(true));
        //Assert.That(rd0.ContainsKey("Key2"), Is.EqualTo(true));

Fix is very simple, see commit

Full PR

API Changes

There is not API changes, only removal of restrictions the current implementation.

Intended Use Case

Usually I group different types of resources by files and merge, for example:
1) Colors.xaml=>Paints.xaml
2) Paints.xaml=>Templates.xaml
3) Converters.xaml=>Templates.xaml
4) Templates.xaml=>Styles.xaml
5) Styles.xaml=>App.xaml

At the current moment I use own Customized Merged Dictionary for Xamarin Forms, but it is implementation is not so beautiful (direct coping merged values into root dictionary). See for details


  • NMackayNMackay GBInsider, University mod

    This is available from

    Adam's PR was merged a while back.

  • MakemanMakeman BYMember
    Please, see details by links. Yes, Merged Dictionaries added by Adam, but there is not support hierarchically merging, only one level (see Adam’s comment on bugzilla).
  • MakemanMakeman BYMember

    Hey, guys! Can anybody review suggested pull request ?

  • Want to throw my support behind this. This is great for complex reusable style libraries or sophisticated apps w/ theming behavior.

  • MarekMierzwaMarekMierzwa USUniversity ✭✭

    Is there any chance to have this feature in some next Forms release? Without this the MergedDictionaries functionality is not very useful now.

Sign In or Register to comment.