[Bug] WebView2 on wpf does not render
When I dump Webview from Microsoft.Web.WebView2.Wpf
the WPF window is white:
but when I'm using Microsoft.Web.WebView2.WinForms
the WebView2 renders correctly:
async Task Main() { var env = await GetWeb2EnvironmentAsync(); if (env != null) { var browser = new WebView2().Dump(); await browser.EnsureCoreWebView2Async (env); browser.Source = new Uri ("https://www.linqpad.net"); } else { // WebView2 not available... } } static Task<CoreWebView2Environment> _environment; public static Task<CoreWebView2Environment> GetWeb2EnvironmentAsync() { return _environment ??= Get(); async Task<CoreWebView2Environment> Get() { var browserFolder = Util.BrowserEngine.GetWebView2ExecutableFolder(); if (browserFolder == null) return null; var dataFolder = Path.Combine( Environment.GetFolderPath(System.Environment.SpecialFolder.LocalApplicationData), "MyApp", "WebView2Data"); try { return await CoreWebView2Environment.CreateAsync(browserFolder, dataFolder); } catch (Exception ex) { // TODO: Log exception... return null; } } }
Comments
WPF elements auto-size and stack when you dump them, so with this control (which doesn't have a minimum size) you either have to put it in a DockPanel, or call the following method to Dump it:
thanks