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

Applying theme dynamically to RadDocking

1 Answer 79 Views
Docking
This is a migrated thread and some comments may be shown as answers.
Arpit
Top achievements
Rank 1
Arpit asked on 04 Mar 2011, 03:12 PM
 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 -
xmlns:my="clr-namespace:POCFeasibilitySketch" 
xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation"

XAML -


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

<telerik:RadMenuItem>    
<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" />
            </telerik:RadMenuItem>   
</telerik:RadMenuItem>   

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

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.
                                 

1 Answer, 1 is accepted

Sort by
0
Pana
Telerik team
answered on 10 Mar 2011, 04:24 PM
Hello Arpit,

Set the command parameter to be something like:
<telerik:RadMenuItem.CommandParameter>
  <telerik:Expression_DarkTheme />
</telerik:RadMenuItem.CommandParameter>
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,
Pana
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!
Tags
Docking
Asked by
Arpit
Top achievements
Rank 1
Answers by
Pana
Telerik team
Share this question
or