Maximizing a SizeToContent="WidthAndHeight"

Ribbon for WPF Forum

Posted 12 years ago by Simon Deguire
Version: 1.0.0342
Environment: Windows XP (32-bit)
Avatar
Hi, when maximizing a SizeToContent="WidthAndHeight" ribbonwindow, the content is not stretched, it is only placed at the top of the screen.

Comments (4)

Posted 12 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Thanks Simon, we'll add this to the TODO list.


Actipro Software Support

Posted 12 years ago by Simon Deguire
Avatar
Was it supposed to be in the v1.0.0345? Because I still have the bug.
Posted 12 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Simon,

Sorry but no it was not fixed in build 345. It's still on the TODO list. You can always check the Release History in the Readme to see what is new in a build.


Actipro Software Support

Answer - Posted 7 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

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.


Actipro Software Support

The latest build of this product (v2019.1 build 0681) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.