Applying theme dynamically to RadDocking

2 posts, 0 answers
  1. Arpit
    Arpit avatar
    10 posts
    Member since:
    Jun 2009

    Posted 04 Mar 2011 Link to this post

     I am unable to apply the theme dynamically using ICommand , here I am having the Grid which is having the radMenuItem and radDocking and I want to apply the theme to the whole layoutroot (which includes Raddocking )when user choose the theme from the radmenuitem.

    But I am unable to apply the theme, May be the bold line underneath is incorrect. please help me in this regards.

     I have all the themes dlls refrenced.

    Namespace -

    XAML -

            <Grid x:Name="LayoutRoot">
                <my:ThemeChangedCommand x:Key="themeCommand"/>
                <RowDefinition Height="0.04*"/>       
                <RowDefinition Height="*"/>

    <telerik:RadMenuItem Header="Themes" x:Name="_themeMenuItem">
                    <telerik:RadMenuItem Header="Expression Blend"  Command="{StaticResource themeCommand}" CommandParameter="Expression_Dark"/>
                    <telerik:RadMenuItem Header="Windows 7" Command="{StaticResource themeCommand}" CommandParameter="Windows7" />

     <telerikDocking:RadDocking Margin="8" Grid.Row="1" x:Name="RadDockingPanel">

    This is my COMMAND CLASS
    namespace POCFeasibilitySketch
        public class ThemeChangedCommand:ICommand
            public bool CanExecute(object parameter)
                return true;

            public event EventHandler CanExecuteChanged;

            public void Execute(object parameter)
                MainPage myMainPageObj = new MainPage();
                string themeName = parameter as string;

                Theme customTheme = new Theme(
                new Uri("/Telerik.Windows.Themes." + themeName + ";component/themes/Generic.xaml"               ,UriKind.RelativeOrAbsolute));
                StyleManager.SetTheme(myMainPageObj.LayoutRoot, customTheme);
                if (CanExecuteChanged != null)
                    CanExecuteChanged(this, new EventArgs());

    please help me in this regards.
  2. Pana
    Pana avatar
    748 posts

    Posted 10 Mar 2011 Link to this post

    Hello Arpit,

    Set the command parameter to be something like:
      <telerik:Expression_DarkTheme />
    And just apply it when executed.

    Also setting the theme on the root will not propagate the theme to all controls. You will have to create somewhat property and bind the telerik:StyleManager.Theme to it.

    Best wishes,
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
  3. DevCraft R3 2016 release webinar banner
Back to Top