Resolved Background="Black" draws with a white background at first?

GregJ7

Member
Joined
Nov 23, 2024
Messages
20
Programming Experience
10+
Any idea why a newly created WPF project with some attributes added to the window draws with a white background (immediately overdrawn with a black one)? In my mind a window with a white background wouldn't ever even exist—at least at a time when any drawing is done.

C#:
<Window x:Class="GridMazeEditor.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:GridMazeEditor"
        mc:Ignorable="d"
        Title="Grid Maze Editor" Width="1250" Height="1000" Background="Black" Loaded="MainWindow_Loaded" SizeChanged="MainWindow_SizeChanged">
</Window>
Thanks.
 
I can see this when debugging, but not when starting the app by itself outside VS.
 
From what I recall, that initial white background is the default Windows client area before the WPF DirectDraw surface is layered over it to do the WPF drawing. If you play with your Windows settings (via PowerToys), you might be be able to change the default Windows colors including the Windows client area. It used to be much easier to do that tweak back in the Windows 3.1 days up to the Windows 7 days, but not as much anymore.
 
Back
Top Bottom