views:

533

answers:

2

I have a couple of listboxes on a WPF Windows, with Height="Auto" Width="Auto" set on the form

The form sizes perfectly on different resolutions, but the problem is that when I press the maximise button a thick "Black L" is visible while the form resizes. I have seen this on quite a few WPF applications, but not had to solve the problem till now.

Is there a way to DoubleBuffer the Window, or call SuspendLayout() in WPF while the controls on the form are resized? How can I get rid of this ugly black L?

+2  A: 

Quoting one of the recent Hanselminutes:

Ian Griffiths: ... There's the win32 cue which is an ordinary win32 message loop, and WPF pools messages off of that and puts them on it's own cue and then deal with it on it's own sweet time, partly because it wants to be able to reorder the events as they come in. It will prioritize certain things above input processing, for example, and that, by the way, is why you get the slightly bizarre repaint handling on resizing WPF applications, you may have noticed you get a little bit of blank space appearing temporarily when you resize a window it's because it's acknowledging the resize event before it actually really does anything with it and then the paints happen slightly out of sync with what's normally there. So there is a win32 message queue but it's not actually the main message queue in WPF and that‘s all sort of implementation details the dispatcher tries to hide as much about it as possible.

It seems relevant to your problem, though I'm not aware of a complete solution. Maybe, you should try to change some Dispatcher priorities?

Yacoder
thank for the suggestion, I will try that
Vault
A: 

Vault, I think this may have something to do with UI virtualization that listboxes perform. Virtualization allows the listbox to load only those UI elements which are being rendered. The listbox does with the help of VirtualizingStackPanel as its ItemsPanelTemplate.

So my guess seems to be... that maximising the window would have pushed the listboxes to generate more UI elements and the delay would have casued the black 'L'.

You can remove virtualization and check it whether the black 'L' still appears. By the way, virtualization is in fact a "good" thing, and turning it off is a generally a bad idea.

Trainee4Life
Removing virtualization has not worked. To be honest, I've seen this issue in quite a few WPF applications, and developers always push the issue to the back of the queue as it is seen as low priority
Vault