Search

WPF Window redraw issue after showing MessageBox by MJosephson

Closed
as Won't Fix Help for as Won't Fix

4
0
Sign in
to vote
Type: Bug
ID: 657687
Opened: 4/6/2011 11:27:04 AM
Access Restriction: Public
0
Workaround(s)
2
User(s) can reproduce this bug
In a call stack that causes a WPF Window to be redrawn (for ex where UI is bound to a ViewModel that has been updated) and also shows a MessageBox, the Window area under the MessageBox is not redrawn.
Details (expand)

Visual Studio/Silverlight/Tooling version

Visual Studio 2010

What category (if any) best represents this feedback?

 

Steps to reproduce

- Drop a datagrid on to a wpf window
- Bind datagrid to collection
- create a method which adds item to collection and also displays a messagebox, where the messagebox overlaps the grid
- when dismissing the messagebox, the messagebox area can still be seen on the window (the window does not repaint area under messagebox)

Product Language

English

Operating System

Windows XP

Operating System Language

English

Actual results

window has "ghost" of messagebox

Expected results

window is redrawn properly
File Attachments
File Name Submitted By Submitted On File Size  
wpfrepaint.zip 4/7/2011 16 KB
wpfrepaint.doc 4/12/2011 28 KB
WpfRepaint.zip 4/12/2011 24 KB
Sign in to post a comment.
Posted by Microsoft on 4/18/2011 at 12:27 PM
The standard MessageBox dialog uses the CS_SAVEBITS flag. This causes the window manager to save the contents of the screen behind the MessageBox dialog into a bitmap, and to restore them when the dialog is dismissed.

Of course, any changes to the contents behind this window should trump whatever the saved bitmap has. Windows detects this in a variety of ways: window moves, invalidate rect calls, GetDC calls, etc.

WPF complicates the story some because it renders to its windows from a separate rendering thread. There have been reported issues where it appears that WPF changes to the contents of the underlying window are not detected by the window manager code that is implementing CS_SAVEBITS, and so the window manager puts back the old content.

This does not happen often, but when it does it can be very annoying. If you encounter one of these scenarios, you can try to work around the problem is various ways.

1) Cause WPF to repaint after dismissing the dialog. This can be difficult, since WPF likes to optimize its rendering passes, and you would have to figure out how to trick it. One idea is to use put a large, transparent rectangle into the adorner layer temporarily.

2) Remove the CS_SAVEBITS class style. This is difficult for several reasons, the least of which is that it is hard to get the dialog HWND.

3) Force the window manager to discard the contents it saved. Raymond talks about some of the triggers that the window manager respects here: http://blogs.msdn.com/b/oldnewthing/archive/2006/04/28/586018.aspx. I think it would be easiest to just call InvalidateRect() on the WPF window. You could even post a Dispatcher work item to do this after the message box is displayed.

This is not a WPF product bug per-se, but rather the unfortunate consequence of some of the design choices (separate render thread, using DX, etc) interacting with other systems. I hope some of these work arounds work for you.

Good luck,
WPF Team
Posted by Microsoft on 4/15/2011 at 1:48 AM
Thanks for your feedback.

We are rerouting this issue to the appropriate group within the Visual Studio Product Team for triage and resolution. These specialized experts will follow-up with your issue.
Posted by Microsoft on 4/12/2011 at 2:32 AM
We are unable to reproduce the issue with your demo project. Could you please give us a video to demonstrate this issue.

Thanks.
Posted by Microsoft on 4/6/2011 at 11:04 PM
Thank you for submitting feedback on Visual Studio 2010 and .NET Framework. In order to efficiently investigate and reproduce this issue, we are requesting additional information outlined below.

Could you please give us a demo project to demonstrate this issue so that we can conduct further research?

Please submit this information to us within 4 business days. We look forward to hearing from you with this information.

Microsoft Visual Studio Connect Support Team
Posted by Microsoft on 4/6/2011 at 12:14 PM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Sign in to post a workaround.