1

I'm trying to fix a rendering issue with a WPF app (a screensaver) that I wrote using VS2015 on Windows 7.

On Windows 10, the config window looks totally different and, more importantly, it's almost useless because of how it renders in Windows 10.

Here are some screenshots. First, windows 7

enter image description here

And Windows 10

enter image description here

While there are lots of little differences, and I expect that, what's unforgivable is the coloring and cut off controls. Check boxes are checked and you can't tell. Radio buttons are selected and you can't tell. You can't even see the bottom control. It's garbage.

I did some research and found that I could override the theme, forcing the use of Aero. I don't know if that will fix my problem and I'm having trouble making it work.

According to my research, if I add the following to App.xaml, it may fix things.

<Application.Resources>
     <ResourceDictionary Source="/PresentationFramework.Aero;component/themes/Aero.NormalColor.xaml" />
     <ResourceDictionary Source="pack://application:,,,/WPFToolkit;component/Themes/Aero.NormalColor.xaml" />
</Application.Resources>

But, doing that gives me a warning in VS2017:

The property "Resources" can only be set once.

So, I can't even test it. I have yet to find a way around this. How do I make it work?

---------- UPDATE 1 ----------

With help from comments I got to:

<Application.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="/PresentationFramework.Aero;component/themes/Aero.NormalColor.xaml" />
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</Application.Resources>

However, now the app will not run at all.

Your app has entered a break state, but there is no code to show because all threads were executing external code (typically system or framework code).

Original source on GitHub

Leezard
  • 143
  • 6
  • 1
    What is your win 10 dpi-scaling? – Stefan Aug 20 '17 at 06:16
  • @Stefan Default, I haven't changed it. – Leezard Aug 20 '17 at 06:17
  • The default depends on your screen resolution. You might want to check this post: https://stackoverflow.com/questions/13448606/how-do-i-create-dpi-aware-wpf-application – Stefan Aug 20 '17 at 06:20
  • @Stefan That is useful information but the more important issue is coloring, I think overriding the theme, using Aero, may help but I'm having problems doing it. Any ideas on that? – Leezard Aug 20 '17 at 06:24
  • This seems like the theme currently in use by your application, which is the default WPF theme, is using colors from System colors. On default control themes, some colors come from system colors and some others are literal values. To solve this, you can try to edit the default themes and set anything using system colors to a color pallete of your own (like the original Windows palletes). – Unknown Coder Aug 20 '17 at 06:24
  • 1
    The following may be of some help: https://blogs.msdn.microsoft.com/wpf/2010/11/30/systemcolors-reference/ – Unknown Coder Aug 20 '17 at 06:26
  • For the colors; if you have styles defined you might want to check them. – Stefan Aug 20 '17 at 06:27
  • 1
    For the resources dictionary; you can merge them (if needed), more on that matter can be found here: https://stackoverflow.com/questions/3419543/adding-a-merged-dictionary-to-a-merged-dictionary#4113594 – Stefan Aug 20 '17 at 06:27
  • Just another thought; I am not aware of the default window background color being black, have you overridden this? – Stefan Aug 20 '17 at 06:29
  • @ASilva Good info on that blog post, it's gonna take some time for to go through it all. – Leezard Aug 20 '17 at 06:36
  • @Stefan Yes, I set the window background to black. As for merging, when I try that I get "The attachable property 'MergedDictionaries' was not found in type 'ResourceDictionary'" as a warning in VS2017. – Leezard Aug 20 '17 at 06:41
  • 2
    Check this example for the dictionaries, it should work. https://stackoverflow.com/questions/35102321/the-attachable-property-mergeddictionaries-was-not-found-in-type-resourcedict, otherwise it's worth a question ;-) – Stefan Aug 20 '17 at 06:54
  • @Stefan Ah, OK. I see what I missed there. That got the warning but now the project will not run. "Your app has entered a break state". Have I mentioned that I'm new to WPF, I was real happy to get that first app to work. Now I pay for my hubris. – Leezard Aug 20 '17 at 07:05
  • 1
    I would post a new question for that – Stefan Aug 20 '17 at 07:29

1 Answers1

2

You are hard coding the size of the Config window.

 Height="358" Width="300"

That's not going to render correctly on modern OS's, where the user has changed the DPI scaling.

In this case it might be better to use the Window SizeToContent property

SizeToContent="WidthAndHeight"

SizeToContent documentation

Walt Ritscher
  • 6,977
  • 1
  • 28
  • 35
  • If you have some ideas about how to overcome the color issues, I'd take it for the answer. It would render trying to override the theme unnecessary. – Leezard Aug 20 '17 at 19:26