Chaning themes dynamically

9 posts, 1 answers
  1. CJ chavez
    CJ chavez avatar
    12 posts
    Member since:
    May 2010

    Posted 26 May 2010 Link to this post

    Hi guys,

    can you guys show me how to change themes for a particular page(User Control) or a ribbon bar(in my case)
    either with the themes you guys provide or the ones from the tool kit from silverlight,

    thanks in advance!
  2. Yavor Georgiev
    Admin
    Yavor Georgiev avatar
    982 posts

    Posted 27 May 2010 Link to this post

    Hello CJ chavez,

     The StyleManager class that ships with our controls possesses the Theme attached property that attaches to all our UI controls. You can change the theme of a control by changing that property. I'm attaching a sample solution where I've bound the Theme property of a RadGridView to a ComboBox of themes and choosing a different theme from the ComboBox changes the theme of the GridView. 

    Sincerely yours,
    Yavor Georgiev
    the Telerik team

    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 Public Issue Tracking system and vote to affect the priority of the items.
  3. CJ chavez
    CJ chavez avatar
    12 posts
    Member since:
    May 2010

    Posted 27 May 2010 Link to this post

    thanks! i'll look into it...
  4. CJ chavez
    CJ chavez avatar
    12 posts
    Member since:
    May 2010

    Posted 27 May 2010 Link to this post

    so I ran your solution but when i change the combo box value the theme does not change... :(
  5. CJ chavez
    CJ chavez avatar
    12 posts
    Member since:
    May 2010

    Posted 27 May 2010 Link to this post

    <telerikRibbonBar:RadRibbonBar telerik:StyleManager.Theme="Office_Silver"  Grid.ColumnSpan="2" Height="175"  HorizontalAlignment="Left" x:Name="radRibbonBar1" VerticalAlignment="Top" Width="989" ApplicationName="myAppl Web" ApplicationButtonImageSource="/RibbonbarNavigationPOC;component/Images/myimg.png" Grid.RowSpan="2" SelectedTabChanged="radRibbonBar1_SelectedTabChanged"
                 
    ...... 
    even statically it doesn't work... am i missing something? it just uses the office_black theme no matter what...
    Note: I'm using the trial version
  6. CJ chavez
    CJ chavez avatar
    12 posts
    Member since:
    May 2010

    Posted 27 May 2010 Link to this post

    let me tell you what my goal is:

    I'm asked to be able to create a theme that i could apply to the ribbon bar(or the whole silverlight app), that theme has to be in a .xaml file so it could be like a standard theme that could be used later on.

    so what I was thinking of doing was using any of your themes, modify it's style, than copy the style to a resource dictionary file, then apply it when needed, if it is possible.

    now if I can't even change the theme statically, i'm stuck...

    please help...
  7. CJ chavez
    CJ chavez avatar
    12 posts
    Member since:
    May 2010

    Posted 27 May 2010 Link to this post

    also i opened a solution that someone else provided from this site, and tried adding a ribbonBar control with the summer theme, and it didn't change...


    <UserControl x:Class="SilverlightApplication3.MainPage" 
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
                     xmlns:controls="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls" 
                 xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Input" 
              
        mc:Ignorable="d" 
        d:DesignHeight="300" d:DesignWidth="400" xmlns:telerikRibbonBar="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.RibbonBar"
        <UserControl.Resources> 
            <Style TargetType="TextBox" controls:StyleManager.BasedOn="Office_BlackTheme"
            </Style> 
             
        </UserControl.Resources>  
     
        <StackPanel x:Name="LayoutRoot" Background="White"
            
            <TextBox Text="SomeText"/> 
            <telerikRibbonBar:RadRibbonBar controls:StyleManager.Theme="Summer" Height="100" Name="radRibbonBar1" Width="398" /> 
        </StackPanel> 
    </UserControl> 
     

  8. Answer
    Yavor Georgiev
    Admin
    Yavor Georgiev avatar
    982 posts

    Posted 28 May 2010 Link to this post

    Hi CJ chavez,

     If you want to create a new theme, you will have to package it in a separate assembly, as outlined here.

    However, if you only want to style several elements, you can do so with XAML Styles, there's no need to create a whole custom theme and try to apply it with the telerik StyleManager.

    We provide the source code of our themes in our RadControls for Silverlight package. You can find them in the Themes folder in your RadControls for Silverlight installation folder. They are a good place to start building custom themes.

    Also, when setting themes in Silverlight, make sure you reference the relevant theme's assembly.

    Please don't hesitate to contact us with any further inquiries.

    Regards,
    Yavor Georgiev
    the Telerik team

    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 Public Issue Tracking system and vote to affect the priority of the items.
  9. CJ chavez
    CJ chavez avatar
    12 posts
    Member since:
    May 2010

    Posted 28 May 2010 Link to this post

    ok so i was able to do it from the code behind... now I'm looking at creating my own theme, thanks for your help! :)
Back to Top