Maximizing a SizeToContent="WidthAndHeight"

Ribbon for WPF Forum

Posted 17 years ago by Simon Deguire
Version: 1.0.0342
Environment: Windows XP (32-bit)
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 17 years ago by Actipro Software Support - Cleveland, OH, USA
Thanks Simon, we'll add this to the TODO list.

Actipro Software Support

Posted 17 years ago by Simon Deguire
Was it supposed to be in the v1.0.0345? Because I still have the bug.
Posted 17 years ago by Actipro Software Support - Cleveland, OH, USA
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 12 years ago by Actipro Software Support - Cleveland, OH, USA

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";

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:

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 (v24.1.2) was released 3 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.