After looking into this item in more detail we can reproduce it with any normal Window, and it is a WPF bug. Basically if you have SizeToContent set and then change the window state programmatically, the bug occurs.
This sample code repros the issue with a native Window:
Window w = new Window();
w.Content = new Button() { Content = "Test" };
((Button)w.Content).Click += (s, ea) => {
w.WindowState = System.Windows.WindowState.Maximized;
};
w.SizeToContent = SizeToContent.WidthAndHeight;
w.Title = "Test";
w.Show();
All you have to do is click the Button and you'll see it happen. Oddly enough, if you click the system-defined Window maximize button, it works as expected.
The reason it occurs on RibbonWindow is that since we use a custom chrome when glass is off, our title bar buttons programmatically set the WindowState like above, thus exposing the bug.
For some more information, Dr. WPF posted a description of the bug and a possible workaround here:
http://social.msdn.microsoft.com/forums/en-US/wpf/thread/c23ad960-12b3-4472-9d24-8eb19742f0cf
Since the system maximize command seems to work fine, we changed our title bar buttons for the next maintenance release to use Windows API calls to alter window state. That also works around the WPF bug without needing any external modifications to code.
Please log in to a validated account to post comments.