Remove RadDocumentPane from PRISM region when closed

2 posts, 1 answers
  1. Marcel
    Marcel avatar
    33 posts
    Member since:
    Jan 2014

    Posted 30 Jul 2015 Link to this post


    I am trying to remove a RadDocumentPane from a region when its closed, but I cant find a way to catch the close event in my viewmodel?

    Whats the best approach to accomplished this with the Docking control?




  2. Answer
    Vladi avatar
    743 posts

    Posted 04 Aug 2015 Link to this post

    Hello Marcel,

    When a RadPane/RadDocumentPane instance is closed via its "Close" button the Close event of the RadDocking control is raised. In that event you can get the closed instances from the event args Pane collection. When working in a more MVVM scenarios you could use our EventToCommandBehavior in order to bring the Close event handler to the ViewModel. The next code snippet shows how the EventToCommandBehavior could be used in the RadDocking control.

    the ViewModel's code should include something like this:
    public class ViewModel
        public ICommand CustomCommand { get; set; }
        public ViewModel()
            this.CustomCommand = new DelegateCommand(OnCustomCommandExecuted);
        private void OnCustomCommandExecuted(object obj)
            var args = obj as Telerik.Windows.Controls.Docking.StateChangeEventArgs;
            var closedPanes = args.Panes.ToList();
            foreach (var pane in closedPanes)
                MessageBox.Show(string.Format("{0} pane closed", pane.Header));
                // Add your custom logic that removes the instance from the region here.

    and the the XAML code:
    <Window ...
                    <telerik:EventBinding Command="{Binding CustomCommand}"

    Hope this is helpful.

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. DevCraft banner
Back to Top