WPF: Windows 7 vs Windows 10 Appearance

前端 未结 1 611
灰色年华
灰色年华 2020-12-20 05:02

I have annoying appearance differences between Windows 10 devices and Windows 7 devices.

I am using WindowStyle=\"None\" and DockPanel dire

相关标签:
1条回答
  • 2020-12-20 05:52

    I think both these is something a lot of people are going to stumble upon when they really start customizing the style of their applications. There's some well established shortcuts to both problems, such as using existing style/libraries for WPF:

    There's a few common Window and style libraries I see:

    • MahApps.Metro is a great library I've used for a long time for getting clean windows and interfaces (especially with 'dark' themes some customers love).
    • Modern UI. Little personal experience, but it's similar in that it has more modern window designs, as well as a big style set. I've seen it used frequently.
    • Elysium. Again, not much experience, but seems active. I've not seen it used as much as the other two.

    These, of course, include a lot of other Metro theming. There are other theme packs available, I've found the Material Design In XAML Toolkit great if a client want's a modern design (Also recognizable, being from Google).

    It looks like you're making your style from scratch, but the above might still be useful for you to simply use for the windows. If you want to go at it yourself there's a lengthy discussion with lot's of answers here.

    For the curved corners, as discussed in the comments, this is as a result of WPF's default behavior on different operating systems. It attempts to select a default style to blend in best with the current operating system. For most applications that just use the default theme, this doesn't often matter.

    When you're styling everything yourself though, it really plays havoc with what you have manually configured, because some properties that work well with the theme you set things up on might be different - like the rounded corners.

    There's two options.

    1. Explicitly set all the properties, so it looks exactly how you want it. Doing this means that even if the 'base' theme changes, it will still look good. This is how those libraries above do things - they define a style completely. Problem is you will have to test it on the different themes manually and it's a bit of work.
    2. Manually set the base theme. (Can also be used for testing in option 1!) You can override which theme your app uses manually rather than letting it use the default for the operating system in much the same way you apply other custom themes, or maybe your own:
    <App.Resources>
      <ResourceDictionary Source="/PresentationFramework.Aero, Version=3.0.0.0,
          Culture=neutral, PublicKeyToken=31bf3856ad364e35,
          ProcessorArchitecture=MSIL;component/themes/aero.normalcolor.xaml"/>
    </App.Resources>
    

    For some reason the above would not appear as code unless encased in quotes...

    0 讨论(0)
提交回复
热议问题