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. WPF application displays differently in Windows 7 and Windows 10

WPF application displays differently in Windows 7 and Windows 10

Scheduled Pinned Locked Moved WPF
helpcsharpcsswpfdata-structures
7 Posts 3 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.
  • J Offline
    J Offline
    Jakob Farian Krarup
    wrote on last edited by
    #1

    Hi :) I have a WPF project working fine in Windows 7, but which has a completely changed layout, when the same project is executed under Windows 10. Do any of you have experiences with this issue? I have found out that WPF loads the current theme/skin from the OS, and that this may be the cause of the skewed layout, but I haven't been able to find any whitepapers or guides with information on how to work around this problem. It is a basic Grid with Stack Panels and Labels in it, if that helps. Any help/ideas/links would be much appreciated :thumbsup: Kind regards - Jakob

    J L 2 Replies Last reply
    0
    • J Jakob Farian Krarup

      Hi :) I have a WPF project working fine in Windows 7, but which has a completely changed layout, when the same project is executed under Windows 10. Do any of you have experiences with this issue? I have found out that WPF loads the current theme/skin from the OS, and that this may be the cause of the skewed layout, but I haven't been able to find any whitepapers or guides with information on how to work around this problem. It is a basic Grid with Stack Panels and Labels in it, if that helps. Any help/ideas/links would be much appreciated :thumbsup: Kind regards - Jakob

      J Offline
      J Offline
      jimmson
      wrote on last edited by
      #2

      Hi Jakob, I had experience with this in the past, but visual changes between two OS versions were usually minor. What do you mean by "completely changed layout"? Can you please elaborate? As you pointed out, issue is (probably) about the styles and templates. By manually setting the whole style (with template etc.), you should be able to ensure same visual appearance on any (compatible) OS.

      J 1 Reply Last reply
      0
      • J jimmson

        Hi Jakob, I had experience with this in the past, but visual changes between two OS versions were usually minor. What do you mean by "completely changed layout"? Can you please elaborate? As you pointed out, issue is (probably) about the styles and templates. By manually setting the whole style (with template etc.), you should be able to ensure same visual appearance on any (compatible) OS.

        J Offline
        J Offline
        Jakob Farian Krarup
        wrote on last edited by
        #3

        Hi Jimmson Thank you for replying. I have been isolating diffent parts of our code, to find the culprit. We are basically building a custom WPF control runtime, to use it for printing, but since it is never shown on the UI, but sent off to the printer, the WPF framework doesn't perform lay-out on the control. I understand, that these lines in the code I am trying to get to work on WIN10, are responsible for enforcing the layout functionality in a non-visible control:

        fixedPage.Measure(sizeOfCustomControlToPrint);
        fixedPage.Arrange(new Rect(new Point(), sizeOfCustomControlToPrint));
        fixedPage.UpdateLayout();

        if I comment these out in WIN10, it seems to be working, but I would really like to understand why. Maybe there is a bug in the WIN10 implementation...? :confused:

        J 1 Reply Last reply
        0
        • J Jakob Farian Krarup

          Hi Jimmson Thank you for replying. I have been isolating diffent parts of our code, to find the culprit. We are basically building a custom WPF control runtime, to use it for printing, but since it is never shown on the UI, but sent off to the printer, the WPF framework doesn't perform lay-out on the control. I understand, that these lines in the code I am trying to get to work on WIN10, are responsible for enforcing the layout functionality in a non-visible control:

          fixedPage.Measure(sizeOfCustomControlToPrint);
          fixedPage.Arrange(new Rect(new Point(), sizeOfCustomControlToPrint));
          fixedPage.UpdateLayout();

          if I comment these out in WIN10, it seems to be working, but I would really like to understand why. Maybe there is a bug in the WIN10 implementation...? :confused:

          J Offline
          J Offline
          jimmson
          wrote on last edited by
          #4

          Have you tried to display this FixedPage in UI to see whether the problem actually is in the FixedPage, or in your custom WPF control runtime?

          J 1 Reply Last reply
          0
          • J jimmson

            Have you tried to display this FixedPage in UI to see whether the problem actually is in the FixedPage, or in your custom WPF control runtime?

            J Offline
            J Offline
            Jakob Farian Krarup
            wrote on last edited by
            #5

            Great idea... It's off to the code-cave! :thumbsup: :-D

            1 Reply Last reply
            0
            • J Jakob Farian Krarup

              Hi :) I have a WPF project working fine in Windows 7, but which has a completely changed layout, when the same project is executed under Windows 10. Do any of you have experiences with this issue? I have found out that WPF loads the current theme/skin from the OS, and that this may be the cause of the skewed layout, but I haven't been able to find any whitepapers or guides with information on how to work around this problem. It is a basic Grid with Stack Panels and Labels in it, if that helps. Any help/ideas/links would be much appreciated :thumbsup: Kind regards - Jakob

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              You're doing "measures" and "arranges" based on a control whose dimensions you have not ascertained. What was a number in Win 7 could now be a NAN in Win 10, or vise-versa. You use the debugger, "Live Visual Tree" and "Live property view" to confirm the heights and width are inherited / accessed as expected.

              The Master said, 'Am I indeed possessed of knowledge? I am not knowing. But if a mean person, who appears quite empty-like, ask anything of me, I set it forth from one end to the other, and exhaust it.' ― Confucian Analects

              J 1 Reply Last reply
              0
              • L Lost User

                You're doing "measures" and "arranges" based on a control whose dimensions you have not ascertained. What was a number in Win 7 could now be a NAN in Win 10, or vise-versa. You use the debugger, "Live Visual Tree" and "Live property view" to confirm the heights and width are inherited / accessed as expected.

                The Master said, 'Am I indeed possessed of knowledge? I am not knowing. But if a mean person, who appears quite empty-like, ask anything of me, I set it forth from one end to the other, and exhaust it.' ― Confucian Analects

                J Offline
                J Offline
                Jakob Farian Krarup
                wrote on last edited by
                #7

                Good points. Thanks, Gerry :thumbsup: :)

                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