Forum Discussion

EnaXnaY's avatar
EnaXnaY
Copper Contributor
Nov 30, 2023

WebView2 at 4K monitor is displayed incorrectly

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

 

 

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);

 

 

Here is the 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>

 

Resources