How to close RadWindow(s) programmaticaly?

2 posts, 0 answers
  1. Dean K.
    Dean K. avatar
    55 posts
    Member since:
    Aug 2011

    Posted 13 Nov 2014 Link to this post

    I need to close RadWindow(s) which are children of Application.Current.MainWindow programmatically but RadWindows present as "Telerik.Windows.Controls.InternalWindow.ChromelessWindowHelper+WindowHostWindow: Window Header" so I'm unable to cast that back to RadWindow and use Close() method. Here is what I tried:

                    foreach (var w in Application.Current.Windows)
                    {
                        var rw = w as RadWindow;
                        if (rw == null) continue;
                        rw.Close();
                    }

                    foreach (var rw in Application.Current.MainWindow.ChildrenOfType<RadWindow>())
                    {                    
                        rw.Close();
                    }

    So, how exactly do I close RadWindow(s) which are children of Application.Current.MainWindow programmatically?
  2. Vladi
    Admin
    Vladi avatar
    744 posts

    Posted 17 Nov 2014 Link to this post

    Hello Dean,

    Thank you for contacting us.

    The easiest way of closing all of the RadWindow instances in the current application is to use the RadWindowManager class and call its CloseAllWindows() method. More information could be found in our online help here. The next code snippet shows the described approach:
    private void CloseAllRadWindows(object sender, RoutedEventArgs e)
    {
        Telerik.Windows.Controls.RadWindowManager.Current.CloseAllWindows();
    }

    Hope this is helpful.

    Regards,
    Vladi
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top