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

Provide dragging out

2 Answers 57 Views
Window
This is a migrated thread and some comments may be shown as answers.
ManniAT
Top achievements
Rank 2
ManniAT asked on 20 Apr 2009, 06:12 PM
Hi,

since the documentation is a bit empty http://www.telerik.com/help/silverlight/radwindow-api-reference.html
I have to ask here:

Is there a way to prevent a window from being dragged out of the control?
Example - I have a HTML - divided into 2 columns (divs) - the first (left) is the silverlight control and right of it is some ASPX content.
Now a user can easily drag out a window "under" the HTML content - that means it is gone.

Is there some property to avoid this?

Regards

Manfred

2 Answers, 1 is accepted

Sort by
0
Accepted
Boyan
Telerik team
answered on 22 Apr 2009, 04:19 PM
Hi Manfred,

There is no property for this. However, it is easy to do it with custom code and put restrictions to the window. You can hook on the LocationChanged event of your window and then add this code:
 
    private void window1_LocationChanged(object sender, RoutedEventArgs e) 
        { 
            Size rootVisualSize = Application.Current.RootVisual.RenderSize; 
 
            window1.Left = Math.Max(0, Math.Min(window1.Left, rootVisualSize.Width - window1.Width)); 
            window1.Top = Math.Max(0, Math.Min(window1.Top, rootVisualSize.Height - window1.Height)); 
        } 

This will restrict moving of the window outside the RootVisual. You can use other coordinates according to your purpose and liking.  The window1.Left/Top  property indicates the coordinates of the top-left corner of the window. I have attached a sample project.

I hope this helps.

Kind Regards,
Boyan
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
ManniAT
Top achievements
Rank 2
answered on 22 Apr 2009, 04:28 PM
Thank you for the good support!
Tags
Window
Asked by
ManniAT
Top achievements
Rank 2
Answers by
Boyan
Telerik team
ManniAT
Top achievements
Rank 2
Share this question
or