Hi Enal,
What you need is not supported by the RadWindow control - it supports just a property of type Thickness which defines a rectangular region (which in your case could be (left, 0, 0, 0) ) and doesn't affect the maximized state. Though a work-around exist for this limitation. Here is an example:
private void OnOpenWindowClicked(object sender, RoutedEventArgs e)
{
var window = new RadWindow { Content = "Some content", RestrictedAreaMargin = new Thickness(50), IsRestricted = true };
new WindowRestrictedMaximizedStateBehavior(window);
window.Show();
}
private class WindowRestrictedMaximizedStateBehavior
{
private RadWindow window;
public WindowRestrictedMaximizedStateBehavior(RadWindow window)
{
this.window = window;
window.WindowStateChanged += this.window_WindowStateChanged;
}
private void window_WindowStateChanged(object sender, EventArgs e)
{
var window = sender as RadWindow;
if (window.WindowState == WindowState.Maximized && window.IsRestricted)
{
window.Dispatcher.BeginInvoke(UpdateWindowSize);
var root = Application.Current.RootVisual as FrameworkElement;
root.SizeChanged += this.root_SizeChanged;
}
else
{
var root = Application.Current.RootVisual as FrameworkElement;
root.SizeChanged -= this.root_SizeChanged;
}
}
private void root_SizeChanged(object sender, SizeChangedEventArgs e)
{
this.UpdateWindowSize();
}
private void UpdateWindowSize()
{
var root = Application.Current.RootVisual as FrameworkElement;
var presenter = window.ParentOfType<WindowPresenterBase>();
presenter.Left = window.RestrictedAreaMargin.Left;
presenter.Top = window.RestrictedAreaMargin.Top;
presenter.Width = root.ActualWidth - window.RestrictedAreaMargin.Left - window.RestrictedAreaMargin.Right;
presenter.Height = root.ActualHeight - window.RestrictedAreaMargin.Top - window.RestrictedAreaMargin.Bottom;
}
}
There is also a way to make more precise way to constraint the dragging and resizing of the RadWindow control, but is more complex to use.
Hope this helps.
Best wishes,
Miroslav Nedyalkov
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>