WebView2 at 4K monitor is displayed incorrectly

Maroš Dziak 0 Reputation points
2023-11-30T08:25:15.2833333+00:00

I have problem with my windows application, that i started to develop. After many issues with displaying correct visual at different dpi settings i came to state, that everywhere it is functional, except my friend's computer with 4K monitor.I have enabled PerMonitorV2 in app.manifest, tried all AutoScale setting for form, added true to gdiScaling app.manifest...Don't know how to solve this, any help?I have tried almost everything, that i've googled. I'm expecting help to solve displaying issues on 4K monitor with WebView2 component.

bug at 4K monitor

app.manifest

<application xmlns="urn:schemas-microsoft-com:asm.v3">
	<windowsSettings>
		<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
		<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2,PerMonitor</dpiAwareness> <!-- DpiUnawareGdiScaled -->
		<gdiScaling xmlns="http://schemas.microsoft.com/SMI/2017/WindowsSettings">true</gdiScaling>
	</windowsSettings>
</application>
webView = new WebView2();  
webView.Visible = false;  
webView.Margin = new Padding(0);  
webView.Padding = new Padding(0);  
webView.Size = new Size(Width, 0);  
webView.AllowExternalDrop = false;  
webView.BackColor = BackgroundColor;  
webView.DefaultBackgroundColor = BackgroundColor;  
await webView.EnsureCoreWebView2Async();  
webView.NavigateToString(text);  
  
fContainer = new FlowLayoutPanel();  
fContainer.FlowDirection = FlowDirection.LeftToRight;  
fContainer.Size = new Size(Width, Height - (fTitle.Bottom - fTitle.Top) - (fActions.Bottom - fActions.Top));  
fContainer.BackColor = ApplicationFramework.FORM_BACK_COLOR;  
fContainer.Padding = new Padding(0);  
fContainer.Margin = new Padding(0);  
fContainer.WrapContents = false;  
fContainer.AutoSize = false;  
fContainer.AutoScroll = false;  
fMain.Controls.Add(fContainer);  
  
fContent = new FlowLayoutPanel();  
fContent.BackColor = ApplicationFramework.FORM_BACK_COLOR;  
fContent.FlowDirection = FlowDirection.TopDown;  
fContent.Size = new Size(Width - (HasMenu ?ApplicationFramework.MENU_WIDTH : 0), Height - (fTitle.Bottom - fTitle.Top) - (fActions.Bottom - fActions.Top));  
fContent.WrapContents = false;  
fContent.Padding = new Padding(0, ApplicationFramework.PADDING, 0, 0);  
fContent.Margin = new Padding(0);  
fContent.AutoScroll = true;  
  
fContent.Controls.Add(webView);
Developer technologies | C#
{count} votes

1 answer

Sort by: Most helpful
  1. Maroš Dziak 0 Reputation points
    2023-12-01T10:01:52.1166667+00:00

    Ok, i found this problem at GitHub, can't do anything about it from my side ;)

    https://github.com/MicrosoftEdge/WebView2Feedback/issues?q=is%3Aissue+is%3Aopen+label%3Abug+wrong+position ;)

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.