Provide dragging out

3 posts, 1 answers
  1. ManniAT
    ManniAT avatar
    877 posts
    Member since:
    Nov 2003

    Posted 20 Apr 2009 Link to this post

    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. Answer
    Boyan
    Admin
    Boyan avatar
    758 posts

    Posted 22 Apr 2009 Link to this post

    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.
  3. DevCraft banner
  4. ManniAT
    ManniAT avatar
    877 posts
    Member since:
    Nov 2003

    Posted 22 Apr 2009 Link to this post

    Thank you for the good support!
Back to Top