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.
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.