2
votes

I'm actually having 2 different flickering issues:

(1) When I create a form with border style set to none, anytime I resize the window there is a good amount of flickering along the edges of the form. This is especially noticeable if I try to resize the form from the top left corner.

(2) When I minimize the form and restore it from the taskbar, for a (very) brief second in the top left corner where the title would normally be you can see a rectangle shape flicker. I think this might be normal windows behavior but it has just become more noticeable due to WPF removing the windows minimize/maximize animations. If I can't fix the flickering directly this way, is it possible to restore the min/max animations without using hacky solutions such as setting the bordersize just before the form minimizes?

Thanks for reading!

1
Do you have the desktop window manager running (dwm.exe)? With the Aero composition engine enabled, resizing should be reasonably fluid, but without it, you may see some tearing. There may also be a slight delay between the Win32 layer resizing the window and WPF re-rendering its content (with or without DWM). It's not something you'd be able to fix.Mike Strobel
Is there any code or Animation executing as a response to the resizing? (OnSizeChanged, WindowState) those can really slow things downEmond
I do have some events but I disabled them as I thought maybe they were causing the problem, but it still happens. I do have dwm running. I know it's probably not possible to have completely smooth resizing of the windows (even visual studio itself doesn't) but I compared this behavior with other programs I have installed and they are significantly smoother. For example, Firefox and Steam both resize smoothly and have no flickering. I know it's not going to be an easy fix because I searched all over before I made this post. Is this a WPF specific issue? Is there a better GUI framework to use?CJF

1 Answers

0
votes

I was fighting the same issue you mention in #1 and it is not specific to borderless WPF forms (though it appears to be dependent on both draw timing and window styles, both of which may change when you change border types). It happens with native apps and apps with full borders as well.

In Windows 10 you can actually see the same type of flickering in Windows Explorer itself when you use the left and/or top window borders.

From my investigations there appear to be at least two overlapping causes, one that dates from pre-Aero days and one that was added on top by Aero. The pre-Aero cause has a workaround but the Aero one still only has a partial solution. Please see this roundup Question/Answer which brings together 10 years of posts on this topic and offers some new insights (too long to paste the content here in this question). Enjoy:

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

Yes, I know on SO the convention is to mark the original question as a dup rather than linking from one question to another, however this case is a bit unusual. My roundup post refers to more than 30 questions on this topic and brings together the most important ideas from them, but it does not include all the ideas from the original questions...that would be impractical. So I don't actually want to see the original questions marked as dups, nor mine, since either way, useful info would be lost. That is because window resize is a broad topic; this Q covers some aspects, my Q covers others.