Two problems I'm experiencing with RadWindow:
1. It's easy for the user to drag a RadWindow off the side of the Silverlight control, so that the window's title bar is no longer visible and hence it cannot be dragged back into view. I've fixed this with the code at the bottom of this note, but it's a hack that will break if you guys change the RadWindow -- wouldn't it be better if it was done by the RadWindow itself?
2. There seems to be no way to have a window that can be minimised but not resized by dragging the window frame. This is a very common scenario for things like tool palettes. Could this be added?
3. While I'm at it, WindowStartupLocation.CenterScreen is wrongly named, and the help is wrong too. It places the window in the centre of the Silverlight control or the browser window (I don't know which) but not the screen.
Cheers,
Max
RadWindow w;
w.LocationChanged += new RoutedEventHandler(w_LocationChanged);
void w_LocationChanged(object sender, RoutedEventArgs e)
{
if (w.Left < 0)
w.Left = 0;
if (w.Top < 0)
w.Top = 0;
Panel p = (Panel)getPopupParent(w);
if (w.Left + w.ActualWidth / 2 > p.ActualWidth)
w.Left = p.ActualWidth - w.ActualWidth / 2;
if (w.Top + w.ActualHeight / 2 > p.ActualHeight)
w.Top = p.ActualHeight - w.ActualHeight / 2;
}
protected FrameworkElement getPopupParent(FrameworkElement e)
{
Popup p = e as Popup;
if (p == null)
return getPopupParent((FrameworkElement)e.Parent);
else
return (FrameworkElement)e.Parent;
}
1. It's easy for the user to drag a RadWindow off the side of the Silverlight control, so that the window's title bar is no longer visible and hence it cannot be dragged back into view. I've fixed this with the code at the bottom of this note, but it's a hack that will break if you guys change the RadWindow -- wouldn't it be better if it was done by the RadWindow itself?
2. There seems to be no way to have a window that can be minimised but not resized by dragging the window frame. This is a very common scenario for things like tool palettes. Could this be added?
3. While I'm at it, WindowStartupLocation.CenterScreen is wrongly named, and the help is wrong too. It places the window in the centre of the Silverlight control or the browser window (I don't know which) but not the screen.
Cheers,
Max
RadWindow w;
w.LocationChanged += new RoutedEventHandler(w_LocationChanged);
void w_LocationChanged(object sender, RoutedEventArgs e)
{
if (w.Left < 0)
w.Left = 0;
if (w.Top < 0)
w.Top = 0;
Panel p = (Panel)getPopupParent(w);
if (w.Left + w.ActualWidth / 2 > p.ActualWidth)
w.Left = p.ActualWidth - w.ActualWidth / 2;
if (w.Top + w.ActualHeight / 2 > p.ActualHeight)
w.Top = p.ActualHeight - w.ActualHeight / 2;
}
protected FrameworkElement getPopupParent(FrameworkElement e)
{
Popup p = e as Popup;
if (p == null)
return getPopupParent((FrameworkElement)e.Parent);
else
return (FrameworkElement)e.Parent;
}