You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
WPF Splashscreen doesn't work correctly on monitors with different dpi's #5070
Does the bug reproduce also in WPF for .NET Framework 4.8?: No
Is this bug related specifically to tooling in Visual Studio (e.g. XAML Designer, Code editing, etc...)? No
Problem description:
Default SplashScreen image appears initially at wrong dpi in the center of the screen. It it then corrects the DPI and then is no longer in the center of the screen. So on a DPI higher than 100%, it appears to shrink and move off center.
Actual behavior:
SplashScreen appears at wrong DPI and then corrects itself (shrinks) and is moved off center.
Expected behavior:
SplashScreen appears at correct DPI and remains in the center of the screen.
Minimal repro:
Using a monitor that is set at a DPI higher than 100% (I was using 250%)
Create a Net Framework 5.0 WPF Application
Add an Image to the project
Set the Properties of the Image to BuildAction = SplashScreen
Run Application and you will see it initially in the center of the screen at a larger non-DPI aware size and then move of center when it is corrected to the DPI aware size
Similar to those and I'm sure sorting those would probably sort this too. But this one is definitely a bug in .NET compared to it working consistently in .NET Framework. It's unusable as is, DPI aware or not DPI aware would be acceptable to me, just not trying to do a bit of both while it loads up, that is the best of no worlds.
Thanks @lindexi, but there doesn't seem much activity on that GitHub, we use very few third party libraries and the ones we do use need a certain level of popularity and support for us to consider using them so we know they should be all good for the future and hopefully well tested.
After a detailed investigation, I believe I've identified the root cause of the issue, along with a potential solution. It appears that the splash screen window is being created and displayed, and then
Or a more modern approach (which is per monitor aware, only supported on Windows 10, version 1607 and later): <dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2</dpiAwareness>
This causes the splash screen window to be created after DPI awareness was enabled, and this fixed the issue for me.
@Nimce This doesn't work for me unfortunately. I have an app.manifest anyway in order to make my WPF app PerMonitorV2 aware; though the splashscreen does not scale (I'm on .NET 9.0.4 and running at 175 %).
@mnissl Can you provide more details? how you integrated the splash screen in your app? or even a video of the problem?
I just tried it again with .NET 9.0.4 and 175 % DPI and works fine with the manifest you provided.
With the manifest (I used the one you provided), the splash screen works correctly, centered and then the program loads:
splashscreen-with-manifest.mp4
Without the manifest (the splash screen changes it's position and it's not centered either):
@mnissl Can you provide more details? how you integrated the splash screen in your app? or even a video of the problem? I just tried it again with .NET 9.0.4 and 175 % DPI and works fine with the manifest you provided.
newSplashScreen("image.png").Show(false,false);
With the manifest (I used the one you provided), the splash screen works correctly, centered and then the program loads:
splashscreen-with-manifest.mp4
Without the manifest (the splash screen changes it's position and it's not centered either):
splashscreen-without-manifest.mp4
Well, don't you see that without the manifest (in your second video), the splash screen first appears bigger before it scales down and changes its position.
With the manifest (in your first video), the position is correct (it's centered), but it is as small as without the manifest.
When you open your splashscreen image with the Windows Photos app (I'm on Windows 11), you will see that it renders the image at 100 %. Select 175 % in the bottom bar to see how big the image should appear in the splashscreen!
Well, as I just see, this issue here is actually about the splashscreen being off-center, whereas issue 947 treats the fact that image isn't scaled correctly. So a proper manifest obviously fixes the position, but the not the scale.
@mnissl I see, sounds like we were talking about slightly different issues.
For me, this behavior with the manifest enabled is appropriate and expected.
Also, keep in mind that the WPF's SplashScreen class just displays a simple raster graphic file (e.g., .png), and those don’t scale automatically with DPI.
For your use case, you might consider implementing a custom splash screen using a WPF window.
That would give you full control and allow for proper scaling, you could use an SVG image or provide different splash images for different DPI settings and show the appropriate one at runtime.
Alternatively (though generally not recommended), you could disable DPI awareness in your app entirely.
This would make Windows "zoom" the splash screen and the rest of your app according to the system's DPI settings.
Just note that this can lead to blurry visuals due to bitmap upscaling.
You can disable DPI awareness in your app by doing the following:
Comment all the DPI-awareness relevant settings in the app manifest to disable them and write this in the app manifest: <dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">false</dpiAware>
Add the DisableDpiAwareness attribute to the app assembly: [assembly: System.Windows.Media.DisableDpiAwareness]
@mnissl I see, sounds like we were talking about slightly different issues.
Exactly: you wrote in the thread for issue 947 that you found a fix and referred to this issue here. But issue 947 is about that "WPF splash screen images are not scaled according to the DPI." So your fix presented here does not fix issue 947.
For me, this behavior with the manifest enabled is appropriate and expected.
Yes, it obviously fixes this issue 5070.
Also, keep in mind that the WPF's SplashScreen class just displays a simple raster graphic file (e.g., .png), and those don’t scale automatically with DPI.
Windows performs the scaling for DPI unaware apps. As WPF apps are DPI aware, one might expect that WPF's SplashScreen class is DPI aware, too.
For your use case, you might consider implementing a custom splash screen using a WPF window.
The idea of using the WPF's SplashScreen class is not to reinvent the wheel and to present the user with a splash screen immediately, not after WPF has started up after multiple seconds.
That would give you full control and allow for proper scaling,
This is what one expects the framework would do out of the box.
@mnissl I see, sounds like we were talking about slightly different issues.
Exactly: you wrote in the thread for issue 947 that you found a fix and referred to this issue here. But issue 947 is about that "WPF splash screen images are not scaled according to the DPI." So your fix presented here does not fix issue 947.
I got your feedback - agreed, this does fix #5070 but not #947.
I had originally commented on 947 because I see both tickets as pointing to the same underlying issue, but I've deleted that comment there to avoid further confusion.
Activity
lindexi commentedon Aug 14, 2021
Maybe Duplicated : #3060 #2942 #947
Link: #2031
james1301 commentedon Aug 16, 2021
Similar to those and I'm sure sorting those would probably sort this too. But this one is definitely a bug in .NET compared to it working consistently in .NET Framework. It's unusable as is, DPI aware or not DPI aware would be acceptable to me, just not trying to do a bit of both while it loads up, that is the best of no worlds.
ryalanms commentedon Aug 17, 2021
Hi @james1301,
Were you able to test this on 4.8? Thanks.
james1301 commentedon Aug 18, 2021
@ryalanms, yeah I tested it and it was fine on .NET Framework 4.8.
james1301 commentedon Aug 8, 2023
@ryalanms, @lindexi has anything happened with this?
lindexi commentedon Aug 8, 2023
@james1301 Now I use https://github.com/kkwpsv/SplashImage . See #2031
james1301 commentedon Aug 8, 2023
Thanks @lindexi, but there doesn't seem much activity on that GitHub, we use very few third party libraries and the ones we do use need a certain level of popularity and support for us to consider using them so we know they should be all good for the future and hopefully well tested.
Nimce commentedon Apr 18, 2025
After a detailed investigation, I believe I've identified the root cause of the issue, along with a potential solution. It appears that the splash screen window is being created and displayed, and then
wpf/src/Microsoft.DotNet.Wpf/src/PresentationCore/ModuleInitializer.cs
Line 52 in 15cc5c1
My possible fix is to have the process DPI aware right from the beginning by changing the application manifest (https://learn.microsoft.com/en-us/windows/win32/hidpi/setting-the-default-dpi-awareness-for-a-process).
If system-aware is enough, then adding this is enough:
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>Or a more modern approach (which is per monitor aware, only supported on Windows 10, version 1607 and later):
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2</dpiAwareness>This causes the splash screen window to be created after DPI awareness was enabled, and this fixed the issue for me.
mnissl commentedon Apr 23, 2025
@Nimce This doesn't work for me unfortunately. I have an
app.manifestanyway in order to make my WPF app PerMonitorV2 aware; though the splashscreen does not scale (I'm on .NET 9.0.4 and running at 175 %).Nimce commentedon Apr 24, 2025
@mnissl Can you provide more details? how you integrated the splash screen in your app? or even a video of the problem?
I just tried it again with .NET 9.0.4 and 175 % DPI and works fine with the manifest you provided.
With the manifest (I used the one you provided), the splash screen works correctly, centered and then the program loads:
splashscreen-with-manifest.mp4
Without the manifest (the splash screen changes it's position and it's not centered either):
splashscreen-without-manifest.mp4
mnissl commentedon Apr 25, 2025
Well, don't you see that without the manifest (in your second video), the splash screen first appears bigger before it scales down and changes its position.
With the manifest (in your first video), the position is correct (it's centered), but it is as small as without the manifest.
When you open your splashscreen image with the Windows Photos app (I'm on Windows 11), you will see that it renders the image at 100 %. Select 175 % in the bottom bar to see how big the image should appear in the splashscreen!
Well, as I just see, this issue here is actually about the splashscreen being off-center, whereas issue 947 treats the fact that image isn't scaled correctly. So a proper manifest obviously fixes the position, but the not the scale.
Nimce commentedon Apr 25, 2025
@mnissl I see, sounds like we were talking about slightly different issues.
For me, this behavior with the manifest enabled is appropriate and expected.
Also, keep in mind that the WPF's
SplashScreenclass just displays a simple raster graphic file (e.g., .png), and those don’t scale automatically with DPI.For your use case, you might consider implementing a custom splash screen using a WPF window.
That would give you full control and allow for proper scaling, you could use an SVG image or provide different splash images for different DPI settings and show the appropriate one at runtime.
Alternatively (though generally not recommended), you could disable DPI awareness in your app entirely.
This would make Windows "zoom" the splash screen and the rest of your app according to the system's DPI settings.
Just note that this can lead to blurry visuals due to bitmap upscaling.
You can disable DPI awareness in your app by doing the following:
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">false</dpiAware>DisableDpiAwarenessattribute to the app assembly:[assembly: System.Windows.Media.DisableDpiAwareness]mnissl commentedon Apr 25, 2025
Exactly: you wrote in the thread for issue 947 that you found a fix and referred to this issue here. But issue 947 is about that "WPF splash screen images are not scaled according to the DPI." So your fix presented here does not fix issue 947.
Yes, it obviously fixes this issue 5070.
Windows performs the scaling for DPI unaware apps. As WPF apps are DPI aware, one might expect that WPF's SplashScreen class is DPI aware, too.
The idea of using the WPF's SplashScreen class is not to reinvent the wheel and to present the user with a splash screen immediately, not after WPF has started up after multiple seconds.
This is what one expects the framework would do out of the box.
Nimce commentedon Apr 25, 2025
I got your feedback - agreed, this does fix #5070 but not #947.
I had originally commented on 947 because I see both tickets as pointing to the same underlying issue, but I've deleted that comment there to avoid further confusion.