Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WPF
  4. Dynamically changing themes from DLL at run-time

Dynamically changing themes from DLL at run-time

Scheduled Pinned Locked Moved WPF
wpftutorialquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Prasoon Chaudhary
    wrote on last edited by
    #1

    How do we change themes dynamically, if themes are stored into a DLL? Generally, if theme is in form of .xaml file, we write in xaml

    And in CS:

    ResourceDictionary skin = new ResourceDictionary();
    skin.Source = new Uri(@"Themes/ShinyRed.xaml", UriKind.Relative);
    Window win = Window.GetWindow(this);
    win.Resources.MergedDictionaries.Clear();
    win.Resources.MergedDictionaries.Add(skin);

    where 'Themes' is folder name and 'ShinyRed.xaml' is theme name. Now, if theme is in form of DLL file, we write in xaml

    where 'ThemeDll' is the name of DLL, and ShinyBlue.xaml is theme name. How to get same result at run-time?

    V 1 Reply Last reply
    0
    • P Prasoon Chaudhary

      How do we change themes dynamically, if themes are stored into a DLL? Generally, if theme is in form of .xaml file, we write in xaml

      And in CS:

      ResourceDictionary skin = new ResourceDictionary();
      skin.Source = new Uri(@"Themes/ShinyRed.xaml", UriKind.Relative);
      Window win = Window.GetWindow(this);
      win.Resources.MergedDictionaries.Clear();
      win.Resources.MergedDictionaries.Add(skin);

      where 'Themes' is folder name and 'ShinyRed.xaml' is theme name. Now, if theme is in form of DLL file, we write in xaml

      where 'ThemeDll' is the name of DLL, and ShinyBlue.xaml is theme name. How to get same result at run-time?

      V Offline
      V Offline
      Varsha Ramnani
      wrote on last edited by
      #2

      I think you can get the result same way as you do it with normal xaml file

      in CS:

      ResourceDictionary skin = new ResourceDictionary();

      Instead of

      skin.Source = new Uri(@"Themes/ShinyRed.xaml", UriKind.Relative);

      Use this

      skin.Source = new Uri(@"/ThemeDll;component/ShinyBlue.xaml", UriKind.Relative);

      Window win = Window.GetWindow(this);
      win.Resources.MergedDictionaries.Clear();
      win.Resources.MergedDictionaries.Add(skin);

      it works fine for me. I hope i got your question correctly.

      Work relieves us from three great evils, boredom, vice, and want.

      P 1 Reply Last reply
      0
      • V Varsha Ramnani

        I think you can get the result same way as you do it with normal xaml file

        in CS:

        ResourceDictionary skin = new ResourceDictionary();

        Instead of

        skin.Source = new Uri(@"Themes/ShinyRed.xaml", UriKind.Relative);

        Use this

        skin.Source = new Uri(@"/ThemeDll;component/ShinyBlue.xaml", UriKind.Relative);

        Window win = Window.GetWindow(this);
        win.Resources.MergedDictionaries.Clear();
        win.Resources.MergedDictionaries.Add(skin);

        it works fine for me. I hope i got your question correctly.

        Work relieves us from three great evils, boredom, vice, and want.

        P Offline
        P Offline
        Prasoon Chaudhary
        wrote on last edited by
        #3

        Thanks! :)

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups