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. Styles aren't apply on Window element in Design Mode when they are coming from a Resource Dictionary included into a .dll reference

Styles aren't apply on Window element in Design Mode when they are coming from a Resource Dictionary included into a .dll reference

Scheduled Pinned Locked Moved WPF
wpfcsharphelpcomdesign
8 Posts 3 Posters 30 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.
  • S Offline
    S Offline
    Simos Sigma
    wrote on last edited by
    #1

    As the title says, I am facing an issue when the styles of a window element are coming from an external resource dictionary which is included into a .dll reference of my project. The problem is that styles aren't apply in design mode!!! To be more specific... I have create a (.NET 4.8 Framework) WPF control library project which, among other stuff, includes some resource dictionary (.xaml) files with styles. To use these styles into a (.NET 4.8 Framework) WPF application project, as far as I know, I can use two ways... WAY ONE: ( [^]Example ) ■ Into the solutions of my application project I add my control library as a new project. ■ I go into my application project and I add a reference that points to my control library project (.csproj) file. ■ I add the .xaml file from my control library project into the App.xaml file of my application project as merged dictionary. ■ And finally, I give the desired style to my window element. Using way one it works fine, in design mode too, but what if, for various obvious reasons, I want to give my control library to someone as a .dll file? Then, as far as I know, I have to use the second way... WAY TWO: ( [^]Example ) ■ Without to add my control library as a new project into the solution of my application project, I go to my application project and I add a reference that points to the .dll file of my control library. ■ I add the .xaml file from my control library project into the App.xaml file of my application project as merged dictionary. ■ And finally, I give the desired style to my window element. But, using way two, styles are applying only when I run the program and not in design mode!!! And this happens only for window elements!!! As you can see if you run the

    Richard DeemingR 1 Reply Last reply
    0
    • S Simos Sigma

      As the title says, I am facing an issue when the styles of a window element are coming from an external resource dictionary which is included into a .dll reference of my project. The problem is that styles aren't apply in design mode!!! To be more specific... I have create a (.NET 4.8 Framework) WPF control library project which, among other stuff, includes some resource dictionary (.xaml) files with styles. To use these styles into a (.NET 4.8 Framework) WPF application project, as far as I know, I can use two ways... WAY ONE: ( [^]Example ) ■ Into the solutions of my application project I add my control library as a new project. ■ I go into my application project and I add a reference that points to my control library project (.csproj) file. ■ I add the .xaml file from my control library project into the App.xaml file of my application project as merged dictionary. ■ And finally, I give the desired style to my window element. Using way one it works fine, in design mode too, but what if, for various obvious reasons, I want to give my control library to someone as a .dll file? Then, as far as I know, I have to use the second way... WAY TWO: ( [^]Example ) ■ Without to add my control library as a new project into the solution of my application project, I go to my application project and I add a reference that points to the .dll file of my control library. ■ I add the .xaml file from my control library project into the App.xaml file of my application project as merged dictionary. ■ And finally, I give the desired style to my window element. But, using way two, styles are applying only when I run the program and not in design mode!!! And this happens only for window elements!!! As you can see if you run the

      Richard DeemingR Offline
      Richard DeemingR Offline
      Richard Deeming
      wrote on last edited by
      #2

      You have already posted this in QA, and been given a very detailed answer: WINDOW style property from an external (DLL) resource dictionary doesn't apply in design mode[^]


      "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

      "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

      Graeme_GrantG 1 Reply Last reply
      0
      • Richard DeemingR Richard Deeming

        You have already posted this in QA, and been given a very detailed answer: WINDOW style property from an external (DLL) resource dictionary doesn't apply in design mode[^]


        "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

        Graeme_GrantG Offline
        Graeme_GrantG Offline
        Graeme_Grant
        wrote on last edited by
        #3

        Both solutions work (Tested before posting the solutions) on both Dot Net and again .net Framework 4.8. The solution used is from a link provided dated 11 Mar 2014 9:17 AM which, back then, was .Net Framework 4.5.2 (ref: .NET Framework version history - Wikipedia[^]) pre-dating the framework version requested by the OP. I don't think that it is so much as the solution does not work, but who is using it.

        Graeme


        "I fear not the man who has practiced ten thousand kicks one time, but I fear the man that has practiced one kick ten thousand times!" - Bruce Lee

        “I fear not the man who has practised 10,000 kicks once, but I fear the man who has practised one kick 10,000 times.” - Bruce Lee.

        S 1 Reply Last reply
        0
        • Graeme_GrantG Graeme_Grant

          Both solutions work (Tested before posting the solutions) on both Dot Net and again .net Framework 4.8. The solution used is from a link provided dated 11 Mar 2014 9:17 AM which, back then, was .Net Framework 4.5.2 (ref: .NET Framework version history - Wikipedia[^]) pre-dating the framework version requested by the OP. I don't think that it is so much as the solution does not work, but who is using it.

          Graeme


          "I fear not the man who has practiced ten thousand kicks one time, but I fear the man that has practiced one kick ten thousand times!" - Bruce Lee

          S Offline
          S Offline
          Simos Sigma
          wrote on last edited by
          #4

          @Graeme_Grand [^] who wrote this [^] and then he deleted it!!! ///// Normally I wouldn't go into this process but after this arrogant irony "I don't think that it is so much as the solution does not work, but who is using it" I will. Υour solution doesn't work for me because into your examples you load the library as .csproj and not as .dll file. You can download [^]this (.NET Framework 4.8) project so to see what I mean. Or you can recreate the whole thing by your self using .NET Framework 4.8 and loading the library as .dll file. And not as a project. If you make it work that way I will humbly apologize, otherwise you will have to. Of course you can just ignore me. The only thing that isn't accepted is the irony and the arrogance... This kind of behavior is shameful to anyone!!!

          Graeme_GrantG 1 Reply Last reply
          0
          • S Simos Sigma

            @Graeme_Grand [^] who wrote this [^] and then he deleted it!!! ///// Normally I wouldn't go into this process but after this arrogant irony "I don't think that it is so much as the solution does not work, but who is using it" I will. Υour solution doesn't work for me because into your examples you load the library as .csproj and not as .dll file. You can download [^]this (.NET Framework 4.8) project so to see what I mean. Or you can recreate the whole thing by your self using .NET Framework 4.8 and loading the library as .dll file. And not as a project. If you make it work that way I will humbly apologize, otherwise you will have to. Of course you can just ignore me. The only thing that isn't accepted is the irony and the arrogance... This kind of behavior is shameful to anyone!!!

            Graeme_GrantG Offline
            Graeme_GrantG Offline
            Graeme_Grant
            wrote on last edited by
            #5

            You missed the point, this is for design time only, not for compiling into a runtime. Of course, it will not work, it is not designed to work that way. You are including a DLL which is in runtime mode and expect a design time property to work as a runtime property. Of course, it won't. Read this if you want to create WPF designer extensions: DesignSurface - WPF Designer Extension[^] ... here is a google search if you want to look for other information on this subject: how to create a WPF designer extension - Google Search[^]

            Graeme


            "I fear not the man who has practiced ten thousand kicks one time, but I fear the man that has practiced one kick ten thousand times!" - Bruce Lee

            “I fear not the man who has practised 10,000 kicks once, but I fear the man who has practised one kick 10,000 times.” - Bruce Lee.

            S 1 Reply Last reply
            0
            • Graeme_GrantG Graeme_Grant

              You missed the point, this is for design time only, not for compiling into a runtime. Of course, it will not work, it is not designed to work that way. You are including a DLL which is in runtime mode and expect a design time property to work as a runtime property. Of course, it won't. Read this if you want to create WPF designer extensions: DesignSurface - WPF Designer Extension[^] ... here is a google search if you want to look for other information on this subject: how to create a WPF designer extension - Google Search[^]

              Graeme


              "I fear not the man who has practiced ten thousand kicks one time, but I fear the man that has practiced one kick ten thousand times!" - Bruce Lee

              S Offline
              S Offline
              Simos Sigma
              wrote on last edited by
              #6

              @Graeme_Grand [^] ///// Oh, I missed the point... And it won't work... Well I have some "bad news". After some tests, it is working, in a way!!! Both, in design time and run time too. Even if I reference my library as .dll to a separate project. But, for some reason that I can't understand for now (since I'm new to WPF) I had to change the target type of </code> from <code>Window</code> to <code>Control</code>. Of course I can't use it like this because I'll loose the ability to style properties of <code>Window</code> element. So what I am trying to find right now is "<i>why is this happening?</i>". Why this issue is happening only with <code>Window</code> element?</x-turndown>

              Graeme_GrantG 1 Reply Last reply
              0
              • S Simos Sigma

                @Graeme_Grand [^] ///// Oh, I missed the point... And it won't work... Well I have some "bad news". After some tests, it is working, in a way!!! Both, in design time and run time too. Even if I reference my library as .dll to a separate project. But, for some reason that I can't understand for now (since I'm new to WPF) I had to change the target type of </code> from <code>Window</code> to <code>Control</code>. Of course I can't use it like this because I'll loose the ability to style properties of <code>Window</code> element. So what I am trying to find right now is "<i>why is this happening?</i>". Why this issue is happening only with <code>Window</code> element?</x-turndown>

                Graeme_GrantG Offline
                Graeme_GrantG Offline
                Graeme_Grant
                wrote on last edited by
                #7

                Simos Sigma wrote:

                Well I have some "bad news". After some tests, it is working, in a way!!

                I'll be surprised if a design time property works as a runtime property from an external DLL. If you close and reopen the window that you want to apply the style to in design time, you will find that you had a false positive. If you do have a working solution, I recommend that you post it as a Tip for others to use. Good luck with it.

                Graeme


                "I fear not the man who has practiced ten thousand kicks one time, but I fear the man that has practiced one kick ten thousand times!" - Bruce Lee

                “I fear not the man who has practised 10,000 kicks once, but I fear the man who has practised one kick 10,000 times.” - Bruce Lee.

                S 1 Reply Last reply
                0
                • Graeme_GrantG Graeme_Grant

                  Simos Sigma wrote:

                  Well I have some "bad news". After some tests, it is working, in a way!!

                  I'll be surprised if a design time property works as a runtime property from an external DLL. If you close and reopen the window that you want to apply the style to in design time, you will find that you had a false positive. If you do have a working solution, I recommend that you post it as a Tip for others to use. Good luck with it.

                  Graeme


                  "I fear not the man who has practiced ten thousand kicks one time, but I fear the man that has practiced one kick ten thousand times!" - Bruce Lee

                  S Offline
                  S Offline
                  Simos Sigma
                  wrote on last edited by
                  #8

                  @Graeme_Grand [^] ///// Yes, I have a 100% working solution right now and I'll post it as soon as I get back the reputation points that were taken away from me for daring to be right!!! PS: Some people in here need a psychiatric follow-up. Frankly...

                  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