WPF Window redraw issue after showing MessageBox - by MJosephson

Status : 

  Won't Fix<br /><br />
		Due to several factors the product team decided to focus its efforts on other items.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.


4
0
Sign in
to vote
ID 657687 Comments
Status Closed Workarounds
Type Bug Repros 2
Opened 4/6/2011 11:27:04 AM
Access Restriction Public

Description

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.
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 Macy [MSFT] 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 Macy [MSFT] 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 Macy [MSFT] 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)