I found app.config
file is not NET6 compatible.
So, AppContextSwitchOverrides … Switches like…
Switch.System.Windows.DoNotScaleForDpiChanges
are transferred from
“appname”.config => “appname”.runtimeconfig.json
In order to control these switches … I had to put new item group into *.csproj
<Project>
...
<ItemGroup>
<RuntimeHostConfigurationOption Include="Switch.System.Windows.DoNotScaleForDpiChanges" Value="true" />
<RuntimeHostConfigurationOption Include="Switch.System.IO.UseLegacyPathHandling" Value="false" />
</ItemGroup>
...
</Project>
When I change the screen DPI and screen resolution at runtime, the application runs with different screen scaling.
When I start my Application on a different monitor which have different screen resolution and different screen scaling, my App is unable to re-scale it’s UI.
I want my application to rescale its UI when used on different monitors with different screen resolutions and different screen scaling
How can I achieve this? I have tried several times but without success. Can someone share a complete example for me?
2
It seems like you copy this post from Microsoft Q & A site, if you facing this same issue that’s fine.This is not a complete answer but I want to give you some concept.
this:
<ItemGroup>
<RuntimeHostConfigurationOption Include="Switch.System.Windows.DoNotScaleForDpiChanges" Value="true" />
<RuntimeHostConfigurationOption Include="Switch.System.IO.UseLegacyPathHandling" Value="false" />
</ItemGroup>
is perfectly working but somehow the Manifest did not call properly when the WPF app start at deifferent DPI or any other screen resolution.
We have to do some tweaking in the *.csproj file so that per monitor DPI Aware is called before the App runs. Now a days .NET run times are JSON based, GOD knows how to set DPI Awareness in VS project file.
Microsoft documentations are poorly outdated they don’t have any guide on how to apply on .NET 8, 6 or any other latest versions.