Changing Themes rumtime

9 posts, 0 answers
  1. Kamlesh
    Kamlesh avatar
    12 posts
    Member since:
    Nov 2008

    Posted 07 Dec 2008 Link to this post

    Hi,

    You have given the example which reloades the ThemeApplication. But in my case, application has several pages on a single page and also it has login page(maintaining the session). So it fails.

    Is there any command from which i can  change the themes for the controls.
    May be like RadControl.SetThemes(). If it is the command then how to use this.


    Thanks
    Kamlesh J
  2. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 08 Dec 2008 Link to this post

    Hello Kamlesh,

    The property you need to set is:
    public partial class App : Application
    {
     public App()
     {
      InitializeComponent();

      Telerik.Windows.Controls.Theme.ApplicationTheme = "Telerik.Windows.Themes.Vista";
     }
    ...
    }

    This will set application-wide theme for ALL Telerik controls. Note that if you want to enable custom made application-wide theme you should put all XAML files in a folder named "themes" and also the resources for each control should be in separate XAML file, named after the control, e.g.
    \
        themes\
            treeview.xaml
            combobox.xaml
            window.xaml
            ...

    If a control is unable to find a needed resource in your theme XAML it will automatically use the same resource from its default theme.

    I hope this helps.

    Best wishes,
    Valeri Hristov
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. SSN
    SSN avatar
    6 posts
    Member since:
    Sep 2008

    Posted 12 Dec 2008 Link to this post

    Hi,
    I do have the same problem, I have set in App.xaml.cs

     

     

     

    public

    void RefreshTheme()

     

     

    {

    if

    (ThemeCode == string.Empty)

     

            Telerik.Windows.Controls.

    Theme.ApplicationTheme = "Telerik.Windows.Themes.Default";

     

     

    else

     

            Telerik.Windows.Controls.

    Theme.ApplicationTheme = ThemeCode;

     

    this

    .RootVisual = new Page1();

     

     

    InitializeComponent();
    }

    public
    string ThemeCode

     

    {

     

      get

     

     

     

          {

    return this.m_ThemeCode;}

     

     

      set

     

     

     

          {

    this.m_ThemeCode = value;}
     }

    But still it takes the default and not refreshing the set property from my page1 when calling RefreshPage().
    Is there any other reset call I need to make, I believe once a new theme is set to ApplicationTheme an event would fire to apply the new change.

    Please help.

    Thanks,
    S.Murali.

     

  4. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 12 Dec 2008 Link to this post

    Hi SSN,

    I am not sure that I completely understand your scenario, but I should note that the themes in Silverlight work only once, since they are based on styles, which can be applied only once. If you are trying to apply a new theme runtime, once the default (or any other) theme was already applied, nothing will happen and this is the expected behavior. In other words, setting ApplicationTheme will work only before the controls are loaded, and only once.

    Greetings,
    Valeri Hristov
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  5. SSN
    SSN avatar
    6 posts
    Member since:
    Sep 2008

    Posted 15 Dec 2008 Link to this post

    Hi Valeri,

    Thanks for your clarification, my requirement was to provide a drop down of available themes and on selecting a theme apply the colors for all the controls.

    Thanks,
    S.Murali.
  6. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 15 Dec 2008 Link to this post

    Hello SSN,

    To do that you will have to reload the entire HTML page when the dropdown selection changes, but this will reset the Silverlight application, which usually brings more problems with persisting state, etc. If you want to try it, I could prepare a simple example that demonstrates how to reload the page.

    All the best,
    Valeri Hristov
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  7. Zero Gravity Chimp
    Zero Gravity Chimp avatar
    40 posts
    Member since:
    Dec 2009

    Posted 10 Jun 2010 Link to this post

    Does this mean that it can't be done without the complications described above?

    I'm trying to do this with gauge with silverlgiht controls Q1/10 SP2.

    This is a common requirement, if it is possible I think you should link the method here.

    Help does not have anything on the topic. I have also downloaded the sample app that resets the rootvisual to change the theme but i have a dashboard application and i need a simple dropdown to change the themes. Any advice?
  8. Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 10 Jun 2010 Link to this post

    Hi guys ,

    In our upcoming beta ( in a few days)  there is something that might be usefull for this scenario.We are introducing a new theme for our Silverlight controls - the Transparent theme.

    It is designed in such way that changing just the background  of the application , would give all the controls a new color scheme .

    You may see it in action  in this blog post. There is a small color swatch in the demo app there , you may click on it to see how you can rapidly switch different colors for the controls by just switching the background.

    Hope this is helpful .

    Best wishes,
    Pavel Pavlov
    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. Zero Gravity Chimp
    Zero Gravity Chimp avatar
    40 posts
    Member since:
    Dec 2009

    Posted 10 Jun 2010 Link to this post

    Great feature, new themes will always go down well. It is still a big question though how i could change to this theme at runtime. One more great theme I cant add to a drop-down list for the user?
Back to Top