How to implement Dynamic theming using PRISM?

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

    Posted 23 Mar 2011 Link to this post

    Hi,

         I am having the requirement where I need to apply dynamic theming. Our Application is using PRISM concept. Had anyone implemented the same having PRISM concept. If Yes please help me.

    I dont want to bind every control of Telerik in XAML using following way - 

    telerik:StyleManager.Theme="{Binding CurrentTheme.Theme}" 

     
    Instead I want to make use of one liner, that is  - 

    StyleManager.ApplicationTheme = theme;

     to apply the theme - which helps to apply theme universally to all the views which comes in different respective regions. 

    This "theme" is an object defined which gets the theme on selectionchanged event of RadComboBox - which is binded to the List<> of themes. For your reference I am pasting the code underneath - 

       public partial class SilverlightControl1 : UserControl
        {    
           ComboBoxItem cmbItemObj = new ComboBoxItem();
              
            Telerik.Windows.Controls.Theme _themeObj = new Telerik.Windows.Controls.Theme();
      
    public SilverlightControl1()
            {
                InitializeComponent();
      
                List<Telerik.Windows.Controls.Theme> listObj = new List<Telerik.Windows.Controls.Theme>();
                listObj.Add(new Telerik.Windows.Controls.Windows7Theme());
                listObj.Add(new Telerik.Windows.Controls.Expression_DarkTheme());
                listObj.Add(new Telerik.Windows.Controls.Office_BlueTheme());
                MyComboBox.ItemsSource = listObj;
            }
      
     private void MyComboBox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
            {
                if(MyComboBox !=null)
                {
                    cmbItemObj = null;
                     _themeObj = (Telerik.Windows.Controls.Theme)MyComboBox.SelectedItem;
                     this.SetTheme(_themeObj);
                }
           }
     private void SetTheme(Telerik.Windows.Controls.Theme theme)
            {
                StyleManager.ApplicationTheme = theme;
                 this.LayoutRoot.Children.Clear();
               // here we tried to redirect to blank page and come back to same - but it did not worked for us.
           }
      
    }

    this way works fine when I implemet the same in an application without prism, but with prism I am not able to implement the same.
    If any one knows about how to implement the Dynamic Theming in an application which uses PRISM please help.

    Regards,
    Arpit Gupta

Back to Top