This is a migrated thread and some comments may be shown as answers.

Theme and ResourceDictionary

1 Answer 185 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Decisive Computing
Top achievements
Rank 2
Decisive Computing asked on 08 Feb 2018, 12:22 PM

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" ?>
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:telerikCommon="clr-namespace:Telerik.XamarinForms.Common;assembly=Telerik.XamarinForms.Common"
             xmlns:telerikInput="clr-namespace:Telerik.XamarinForms.Input;assembly=Telerik.XamarinForms.Input"
             x:Class="Mobile.App">
    <Application.Resources>
        <telerikCommon:RadResourceDictionary>
            <telerikCommon:RadResourceDictionary.MergedDictionaries>
                <!--<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>-->
 
                <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>
                <!--<ResourceDictionary MergedWith="primitives:TelerikThemeStyles"/>
                <ResourceDictionary MergedWith="chart:TelerikThemeStyles"/>
                <ResourceDictionary MergedWith="telerikDataControls:TelerikThemeStyles" />
                <ResourceDictionary MergedWith="dataGrid:TelerikThemeStyles"/>-->
            </telerikCommon:RadResourceDictionary.MergedDictionaries>
        </telerikCommon:RadResourceDictionary>
    </Application.Resources>
</Application>

1 Answer, 1 is accepted

Sort by
0
Stefan Nenchev
Telerik team
answered on 13 Feb 2018, 11:03 AM
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 

Regards,
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
Tags
General Discussions
Asked by
Decisive Computing
Top achievements
Rank 2
Answers by
Stefan Nenchev
Telerik team
Share this question
or