From 5439f9499af4f84147a827e4be4299a41bc48e1a Mon Sep 17 00:00:00 2001 From: Jaime Bernardo Date: Thu, 23 Nov 2023 16:51:48 +0000 Subject: [PATCH] [Peek]Force white background on html after WebView2 update (#29995) --- .../peek/Peek.FilePreviewer/Controls/BrowserControl.xaml.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/modules/peek/Peek.FilePreviewer/Controls/BrowserControl.xaml.cs b/src/modules/peek/Peek.FilePreviewer/Controls/BrowserControl.xaml.cs index 61efadd7fc..0841248971 100644 --- a/src/modules/peek/Peek.FilePreviewer/Controls/BrowserControl.xaml.cs +++ b/src/modules/peek/Peek.FilePreviewer/Controls/BrowserControl.xaml.cs @@ -4,6 +4,7 @@ using System; using System.Threading.Tasks; +using Microsoft.UI; using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; using Microsoft.Web.WebView2.Core; @@ -135,7 +136,8 @@ namespace Peek.FilePreviewer.Controls // Storing the original background color so it can be reset later for specific file types like HTML. if (!_originalBackgroundColor.HasValue) { - _originalBackgroundColor = PreviewBrowser.DefaultBackgroundColor; + // HACK: We used to store PreviewBrowser.DefaultBackgroundColor here, but WebView started returning transparent when running without a debugger attached. We want html files to be seen as in the browser, which has white as a default background color. + _originalBackgroundColor = Colors.White; } // Setting the background color to transparent when initially loading the WebView2 component.