Allow Merged Dirctionaries hierarchically merging RRS feed

  • Question

  • User81600 posted

    [Sorry for links format, I have not permission to post correct links...] [Moved from "bugzilla.xamarin.com/show_bug.cgi?id=60316" 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, current brunch 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 github.com/xamarin/Xamarin.Forms/commit/e22367ebe90783579fa4a7b3b66da196d41a1960

    Full PR github.com/xamarin/Xamarin.Forms/pull/1218

    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, for example: Colors.xaml=>Converters.xaml=>Paints.xaml=>Templates.xaml=>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). github.com/Makeloft/Ace/blob/master/Ace.Zest/Markup/ResourceDictionary.cs

    Monday, October 23, 2017 9:30 PM

All replies

  • User76916 posted

    @Makeman - Can you please format your request, as per the Readme (https://forums.xamarin.com/discussion/84503/please-read-first)

    Monday, October 23, 2017 9:55 PM