Window heigth grows when width changes

Ribbon for WPF Forum

Posted 14 years ago by Simon Deguire
Version: 9.1.0502
Platform: .NET 3.5
Environment: Windows Vista (32-bit)
Avatar
When I change the width of a window trough code, it grows vertically in Vista Aero.
<Ribbon:RibbonWindow x:Class="RibbonWindowResize.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:Ribbon="clr-namespace:ActiproSoftware.Windows.Controls.Ribbon;assembly=ActiproSoftware.Ribbon.Wpf30"
    Title="Window1" Height="300" Width="300">
    <StackPanel Orientation ="Vertical">
        <Button Click="increase">_+ increase</Button>
        <Button Click="decrease">_- decrease</Button>
    </StackPanel>
</Ribbon:RibbonWindow>
using System.Windows;

namespace RibbonWindowResize
{
    /// <summary>
    /// Interaction logic for Window1.xaml
    /// </summary>
    public partial class Window1 
    {
        public Window1()
        {
            InitializeComponent();
        }

        private void increase(object sender, RoutedEventArgs e)
        {
            Width = ActualWidth + 1;
        }

        private void decrease(object sender, RoutedEventArgs e)
        {
            Width = ActualWidth - 1;
        }
    }
}
press + or - on keyboard to change window Width, bug will be visible only in vista aero.

Side note, it would be great to be able to post an entire solution to the thread.

Comments (3)

Posted 14 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Simon,

Unfortunately, this is an issue with the Win32 hooks needed to allow WPF content to be rendered in the non-client area (such as the QAT and Application button). We tested the Microsoft's WPF Ribbon from the CTP, and their RibbonWindow has the same issue.


Actipro Software Support

Posted 14 years ago by Simon Deguire
Avatar
That's unacceptable, did you forward the bug to the MS WPF team?
And how do we fix this for now, you must have a workaround?
Posted 14 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Simon,

Trust me, it's been a very frustrating issue for us and we've spent many hours trying to find a workaround, unfortunately without success. To give you more detail, normally WPF cannot draw in the titlebar area of a window, which is the "non-client" area. We have to intercept various windows messages and tweak the non-client and client area of the Window so that we trick Windows into thinking the client area is over where the non-client area of the Window is. Since WPF can draw in the client area of a Window, by doing the API hack mentioned above, we are able to render WPF content like the application button, QAT, and contextual tab group headers in the title bar area, which is a requirement for ribbon windows.

Unfortunately this API trick also causes the side effect you posted about. Again we have spent many hours in the past trying to extend the client area into the non-client area in different ways, but have not found another way that works successfully for our ribbon needs. We've even tested a couple other competitors and they have the same issue.

Now when the end user resizes the window it works fine. So we did a test of using an API call to resize the window and that worked:
IntPtr hwnd = new WindowInteropHelper(this).Handle;  
if (hwnd == IntPtr.Zero)  
    return;  
  
SetWindowPos(hwnd, IntPtr.Zero, 0, 0,  
    (int)Math.Ceiling(this.ActualWidth - 1), (int)Math.Ceiling(this.ActualHeight),
    SWP_NOMOVE | SWP_NOZORDER | SWP_FRAMECHANGED);
You can use that as a workaround. In addition we'll wrap this code for you in a SetSize method that will be added in the upcoming maintenance release, which may even be released later today.


Actipro Software Support

The latest build of this product (v24.1.2) was released 1 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.