Troubles with creating custom theme based on existing

3 posts, 1 answers
  1. Лена
    Лена avatar
    9 posts
    Member since:
    Oct 2015

    Posted 27 Oct 2015 Link to this post

    Hello! 

    I'm trying to create custom theme based on Windows8 theme. I did everything as it said in the topic http://docs.telerik.com/devtools/silverlight/styling-and-appearance/stylemanager/creating-a-custom-theme/common-styling-apperance-themes-custom-theme-project.html

    1. I've created Silverlight Class Library project with "Themes" folder

    2. I've copied xaml files from "Themes" folder of Windows8 theme. I want to create a copy of Windows8 theme and modify it later, so I've copied all of files.

    3. I've created "General.xaml" file with code like this

        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="/SomeDefaultTheme;component/Themes/Controls.Chart.xaml" />
            <ResourceDictionary Source="/SomeDefaultTheme;component/Themes/Controls.Data.xaml" />
            <!--and so on-->
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>

     4. I've created theme class

    public class SomeDefaultTheme : Telerik.Windows.Controls.Theme
        {
            public SomeDefaultTheme()
            {
                this.Source = new Uri("/SomeDefaultTheme;component/Themes/Generic.xaml", UriKind.Relative);
            }
        }

    5. I've attached my theme to my application using StyleManager

    telerik:StyleManager.Theme="{Binding Path=CurrentTheme, Source={StaticResource userInterfaceStyles}}"

     But I have no effect. If I apply styles of standart theme, I see changes, but if I use my custom theme, nothing happends. 

     

    Also, I have strange error in General.xaml. The root "ResourceDictionary" element is underlined and I see an error "Element is already the child of another element". 

    I've tried to attach project code, but I can't attach an archive. 

        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="/ITPSDefaultTheme;component/Themes/Controls.Chart.xaml" />
            <!--and others-->
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="/ITPSDefaultTheme;component/Themes/Controls.Chart.xaml" />
            <!--and others-->
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
  2. Answer
    Masha
    Admin
    Masha avatar
    355 posts

    Posted 29 Oct 2015 Link to this post

    Hi Lena,

    We generally recommend utilizing an implicit styles(NoXaml binaries) approach for creating custom themes. If you include all default styles in your application, you can create custom styles based on them and only change those elements that don't fit in the overall look of your application. I've attached a sample project demonstrating this approach.

    I hope this helps.


    Regards,
    Masha
    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
  3. DevCraft banner
  4. Лена
    Лена avatar
    9 posts
    Member since:
    Oct 2015

    Posted 30 Oct 2015 Link to this post

    Hi Masha! 

    Thank you, looks like it helped! 

    I've done following:

    1. To MergedDictionary block I've added links to windows8 resource dictionaries. Likt this:

    <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="/CustomWindows8Theme;component/Styles/Telerik.Windows.Controls.Navigation.xaml"/>
            <ResourceDictionary Source="/Telerik.Windows.Themes.Windows8;component/Themes/Telerik.Windows.Controls.Docking.xaml"/>
    </ResourceDictionary.MergedDictionaries>

    2. StyleManager example from my post doesn't work well. So I used such code

    public App()
            {
                ...
                StyleManager.ApplicationTheme = new ITPSDefaultTheme();
                InitializeComponent();
            }

    in App.xaml.cs

    3. I've forgot BasedOn property in my styles. The right syntax is: 

    <Style TargetType="telerikNavigation:RadToolBar" BasedOn="{StaticResource RadToolBarStyle}" >

     

    And now it works! :) 

Back to Top