This is a migrated thread and some comments may be shown as answers.

Can't maximize the dialog when using Maxheight and Resizing

1 Answer 13 Views
Window
This is a migrated thread and some comments may be shown as answers.
khai
Top achievements
Rank 1
khai asked on 29 Nov 2013, 07:38 AM
Hi Telerik,

I have a problem on using RadWindow. Because its content is loaded on demand so I want it can re-size automatically.
This below code make the radwindow cant maximize when I click Maximize button.
Hope your help!
 
MinHeight="100" MaxHeight="{Binding WindowHeight, Mode=TwoWay}"
SizeChanged="OnSizeChanged"
private void OnSizeChanged(object sender, SizeChangedEventArgs e)
        {
            Size appSize = Application.Current.RootVisual.RenderSize;
            Left = Math.Round((appSize.Width / 2) - (ActualWidth / 2), 0);
            Top = Math.Round((appSize.Height / 2) - (ActualHeight / 2), 0);
        }

1 Answer, 1 is accepted

Sort by
0
Kalin
Telerik team
answered on 02 Dec 2013, 02:15 PM
Hi Khai,

The reason for the explained behavior is because of the MaxHeight which is affecting the Height of the maximized Window. However what you can do is to reset the MaxHeight in the SizeChanged event handler when the Window is in Maximized state and set it back when it is not. Please check the following code snippet below, I have used a variable to keep the old value:

private double oldMaxHeight;
private void RadWindow_SizeChanged(object sender, SizeChangedEventArgs e)
{
    var window = sender as RadWindow;
 
    if (window.WindowState == System.Windows.WindowState.Maximized)
    {
        if (this.oldMaxHeight == 0)
        {
            this.oldMaxHeight = window.MaxHeight;
            window.MaxHeight = Application.Current.RootVisual.RenderSize.Height;
        }
    }
    else
    {
        if (this.oldMaxHeight != 0)
        {
            window.MaxHeight = this.oldMaxHeight;
            this.oldMaxHeight = 0;
        }
    }
 
    Size appSize = Application.Current.RootVisual.RenderSize;
    Left = Math.Round((appSize.Width / 2) - (ActualWidth / 2), 0);
    Top = Math.Round((appSize.Height / 2) - (ActualHeight / 2), 0);
}


Hope this helps.

Regards,
Kalin
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
Window
Asked by
khai
Top achievements
Rank 1
Answers by
Kalin
Telerik team
Share this question
or