2

Im beginning in my journey of learning WPF. After a few days of coding I see that whenever I resize any WPF form I get a black border on the bottom and right while resizing, like an artifact, as if the screen is too slow. When working with winforms I never noticed this.

Like so :

enter image description here

Is this a known problem? any simple workaround?

EDIT 1:

Seems its related to the graphics driver, I only work on laptops with weakish gfx cards, so does anyone else have this issue? (Im also using Win7 SP1)

sprocket12
  • 5,040
  • 16
  • 56
  • 122
  • possible duplicate of [How to fix the WPF form resize - controls lagging behind and black background?](http://stackoverflow.com/questions/1382915/how-to-fix-the-wpf-form-resize-controls-lagging-behind-and-black-background) – ghord Mar 31 '14 at 07:00

2 Answers2

1

It's a known problem, and it's unlikely that it will be fixed. There is a work-around that reduces the impact of this problem if your background is sufficiently uniform: https://stackoverflow.com/a/14309002/33080

My understanding of the underlying cause is that WPF controls lag behind on resizes: WPF draws them in the "wrong" location briefly. See the linked question for a demonstration.

Community
  • 1
  • 1
Roman Starkov
  • 52,420
  • 33
  • 225
  • 300
0

If you resize a window it has to redraw. This takes some time and also it occurs after the window manager already resized your window and shows it; in that case you'll get a black border in WPF and one with the normal window background (grey, usually) in Windows Forms.

Usually all you can hope for there is that the computer is fast enough with the redraw to not show it.

Joey
  • 316,376
  • 76
  • 642
  • 652
  • It seems it would make more sense if WPF just scaled the window temporarily -- again, this problem does not exist with WinForms. -- Kind of sad that they introduced such a big flaw in WPF. – BrainSlugs83 Jun 24 '14 at 03:39
  • 1
    @BrainSlugs83: Scaling the window temporarily makes for kind of a jarring look when your UI temporarily gets blurry and the snaps back into place resized. Keep in mind that not everything gets scaled uniformly when you resize a window (short of putting everything into a single ViewBox). Things like a status bar or menu bar also likely never scale vertically. This is a problem in all applications and the easiest way to get around it is making your form layouts simpler so that it redraws fast. Which is almost always a good idea anyway. – Joey Jun 24 '14 at 05:04
  • That's true -- I hadn't thought of that at the time -- but there is a workaround -- instead of scaling, it just fills in the proper background color -- so you almost don't even notice it. -- Right now, the black background is just harsh. – BrainSlugs83 Jan 25 '15 at 03:11