Theme and ResourceDictionary

2 posts, 0 answers
  1. Decisive Computing
    Decisive Computing avatar
    18 posts
    Member since:
    Mar 2015

    Posted 08 Feb 2018 Link to this post

    After reading and following your examples on customizing the style of your controls I am more confused than ever.

    1. Why do I need a RadResourceDictionary? Isn't a regular ResourceDictionary sufficient?

    2. After changing my App.xaml to RadResourceDictionary I get runtime errors that the Telerik style keys already exist in the dictionary.

    Below is what I have. Please help and I desperately need to change your default colors to match my design.

    <?xml version="1.0" encoding="utf-8" ?>
                    <!--<ResourceDictionary MergedWith="telerikCommon:BlueResources">
                        --><!-- ListView --><!--
                        <Color x:Key="ListViewItemBorderColor">Orange</Color>
                        <Color x:Key="ListViewSelectionColor">Orange</Color>
                        <Color x:Key="ListViewBackgroundColor">Black</Color>
                        <Color x:Key="ListViewForegroundColor">Orange</Color>
                        <Color x:Key="ListViewSelectionBackgroundColor">Black</Color>
                    <ResourceDictionary MergedWith="telerikInput:TelerikThemeStyles">
                        <!-- MaskedInput -->
                        <Color x:Key="MaskedInputBorderColor">Red</Color>
                        <Color x:Key="MaskedInputWatermarkColor">#919191</Color>
                        <Color x:Key="MaskedInputErrorColor">#D50002</Color>
                        <Color x:Key="MaskedInputDisplayedTextColor">#4A4949</Color>
                    <!--<ResourceDictionary MergedWith="primitives:TelerikThemeStyles"/>
                    <ResourceDictionary MergedWith="chart:TelerikThemeStyles"/>
                    <ResourceDictionary MergedWith="telerikDataControls:TelerikThemeStyles" />
                    <ResourceDictionary MergedWith="dataGrid:TelerikThemeStyles"/>-->
  2. Stefan Nenchev
    Stefan Nenchev avatar
    665 posts

    Posted 13 Feb 2018 Link to this post

    Hello Brian,

    Thank you for the detailed information.

    1. Regarding the usage of the RadResourceDictionary. At the time of implementing the functionality, Xamarin.Forms' default ResourceDictionary class did not support MergedDictionaries. That is why we had to extend the ResourceDictionary so that it can be used within the Theming. We will consider how we can change the theming mechanism in the future so that the default dictionary can be used.

    2. As for the exception you are observing. I have managed to replicate it from my side when using the first approach of modifying the theme's colors. I have tested the issue with the second approach, where you are creating a custom ResourceDictionary and use it instead of the default BlueResources one. In this case everything works fine.

    It seems that the first approach is broken when using the .NET standard approach. In a solution with a Shared project both approaches work. We have to investigate the matter in details in order to observe what changes in the Xamarin framework might be causing this. I have logged the behavior as a bug and you can track it here - Theming: Modifying the default resources results in ArgumentException. Please subscribe to the item in order to receive automatic notifications. I have added 1000 points to your account for reporting the behavior. 

    Please check the attached sample where you can find how to achieve the modifications and update me whether it was useful.

    Have a great rest of the week 

    Stefan Nenchev
    Progress Telerik
    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 Feedback Portal and vote to affect the priority of the items
Back to Top