How to fix the WPF form resize - controls lagging behind and black background?

Viewed 7746

I have a very simple WPF window - the only thing in it is a right-aligned button. When I resize the window by dragging the left boundary, the button jumps around - a lot. Try it yourself, drag the left boundary back and forth.

Additionally, a black background becomes exposed temporarily during resizes.

In this question, I asked a similar question about Windows Forms. The only answer I got suggested that this is fixed in WPF, however, amazingly, not only is it not fixed, but WPF also adds a second visual bug - the temporary black background.

Here's what the control lag looks like; this occurs when I resize the window by its top border (recorded with a camera because screen-cap made it less obvious by making everything slow):

                                                  enter image description here

Example of the black border: this was captured while resizing the window; it's only like this for a split second but it's very noticeable:

                                      enter image description here

Am I doing something wrong? How can I have my controls stay visually in one place during resizes? How can I avoid the black border?

Note: the button ends up in the correct place eventually - it only jumps around briefly during the resize.

5 Answers

Other answers have addressed how to fill in a different background colors to try and mitigate the effect of WPF slow drawing.

I can't offer any magic to speed up WPF but I can offer some insight about where the black is coming from.

The visual bug in your first screenshot is due to an extra layer of resize problem that Aero added, and there is a partial workaround.

I was fighting the issue of ugly live-resize in native Win32 apps and I created a roundup Question/Answer which brings together 10 years of posts on resize woes and offers some new insights (too long to paste the content here in this question). Please see:

How to smooth ugly jitter/flicker/jumping when resizing windows, especially dragging left/top border (Win 7-10; bg, bitblt and DWM)?

Related