I’m creating a .net app that uses webview2 to view sveltekit static app or any static HTML file, but I got this weird graphical issue as shown in this video: https://imgur.com/W9NdOjT
any suggestion as to how I can remove it?
I tried doublebuffer and didn’t work
this is the main part of my code:
public partial class MainForm : Form
{
public MainForm()
{
InitializeComponent();
InitializeWebView();
}
private async void InitializeWebView()
{
await webView.EnsureCoreWebView2Async();
webView.CoreWebView2.AddHostObjectToScript("myMethods", new MyMethods());
webView.CoreWebView2.Settings.AreDevToolsEnabled = Program.IsDebug;
webView.CoreWebView2.Settings.AreDefaultContextMenusEnabled = Program.IsDebug;
string svelteKitPath = Program.IsDebug ? "http://localhost:3005" : Path.Combine(Application.StartupPath, "wwwroot", "index.html");
webView.Source = new Uri(svelteKitPath);
}
private void InitializeComponent()
{
webView = new MyWebView2();
((System.ComponentModel.ISupportInitialize)webView).BeginInit();
SuspendLayout();
//
// webView
//
webView.Dock = DockStyle.Fill;
webView.Name = "webView";
//
// MainForm
//
ClientSize = new Size(800, 450);
Controls.Add(webView);
this.DoubleBuffered = true;
this.Name = "MainForm";
this.Text = "MainForm";
((System.ComponentModel.ISupportInitialize)(webView)).EndInit();
this.ResumeLayout(false);
}
private class MyWebView2 : Microsoft.Web.WebView2.WinForms.WebView2
{
public MyWebView2() : base()
{
this.DoubleBuffered = true;
}
}
}