Switching theme of main window at runtime

6 posts, 0 answers
  1. Uwe Zimmermann
    Uwe Zimmermann avatar
    5 posts
    Member since:
    Oct 2009

    Posted 26 Oct 2014 Link to this post

    I'm using RadWindow as main window of a wpf application. Switching theme of all other controls at runtime using implicit styling approach works great. But i can't switch theme of main window?!? Is there any way to get this working?
  2. Kalin
    Admin
    Kalin avatar
    1209 posts

    Posted 27 Oct 2014 Link to this post

    Hi Uwe,

    In order to get the Style changing correctly of RadWindow used as MainWindow you would need to merge the following Style each time the theme is switched:
    <Style TargetType="local:MainWindow" BasedOn="{StaticResource RadWindowStyle}" />

    Or alternately you could set the Style property of the MainWindow the follow way:
    Style="{DynamicResource RadWindowStyle}"

    This way the MainWindow will be receiving the correct Style once the theme is switched.

    Hope this helps.

    Regards,
    Kalin
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. UI for WPF is Visual Studio 2017 Ready
  4. Uwe Zimmermann
    Uwe Zimmermann avatar
    5 posts
    Member since:
    Oct 2009

    Posted 27 Oct 2014 Link to this post

    Hi Kalin,

    thanks for your answer.

    Your second approach does not work (window will be transparent).

    Merging the style (your first approach) i tryed before i started this thread, but eventually i did something wrong. Could you give me some code showing how to merge the style correctly?
  5. Kalin
    Admin
    Kalin avatar
    1209 posts

    Posted 27 Oct 2014 Link to this post

    Hi Uwe,

    The approach with the DynamicResource should work as well. However I'm attaching a sample project, demonstrating the first approach I suggested you in my previous post.

    Hope this helps.

    Regards,
    Kalin
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  6. Uwe Zimmermann
    Uwe Zimmermann avatar
    5 posts
    Member since:
    Oct 2009

    Posted 27 Oct 2014 Link to this post

    Hi Kalin,

    thanks for your sample project. It works like a charm.
  7. Kalin
    Admin
    Kalin avatar
    1209 posts

    Posted 28 Oct 2014 Link to this post

    Hi Uwe,

    I'm glad it helped. If you have any other questions, let us know.

    Regards,
    Kalin
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top
UI for WPF is Visual Studio 2017 Ready