Bradley Uffner Bradley Uffner - 17 days ago 11
C# Question

WPF window flickers when resizing

I have a very simple window, defined with the following XAML (There is currently no logic in the View Model):

<Window x:Class="WpfViewer.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:local="clr-namespace:WpfViewer"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Title="MainWindow"
Width="525"
Height="350"
d:DataContext="{d:DesignInstance local:MainWindowVm}"
mc:Ignorable="d">
<Grid Margin="8">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="200" />
<ColumnDefinition Width="8" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<StackPanel Grid.Row="0"
Grid.Column="0"
Grid.ColumnSpan="3"
Orientation="Horizontal" Margin="0,0,0,8">
<TextBlock Text="Object" />
<!-- breadcrumbs -->
</StackPanel>
<Border Grid.Row="1"
Grid.Column="0"
BorderBrush="Black"
BorderThickness="1" />
<GridSplitter Grid.Row="1"
Grid.Column="1"
Width="8"
Background="{DynamicResource {x:Static SystemColors.WindowBrush}}"
ResizeBehavior="PreviousAndNext" />
<Border Grid.Row="1"
Grid.Column="2"
BorderBrush="Black"
BorderThickness="1" />
</Grid>
</Window>


As the user resizes the window, the new area of the window flickers black.
enter image description here

Is there any way to prevent this flickering?




I do not beleive that this existing question is a duplicate. It involves completely custom windows, with animations.

Prevent WPF window flicker

Answer

This is being caused by the debug-time additions to the window. Try running it without the debugger attached.

Comments