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

Remove RadDocumentPane from PRISM region when closed

1 Answer 91 Views
Docking
This is a migrated thread and some comments may be shown as answers.
Marcel
Top achievements
Rank 1
Marcel asked on 30 Jul 2015, 03:35 PM

Hello,

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?

 

Marcel

 

1 Answer, 1 is accepted

Sort by
0
Accepted
Vladi
Telerik team
answered on 04 Aug 2015, 06:33 AM
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 ...
        xmlns:local="clr-namespace:DockingClosedEvent"
         ...>
    <Window.DataContext>
        <local:ViewModel/>
    </Window.DataContext>
    <Grid>
        <telerik:RadDocking>
            <telerik:EventToCommandBehavior.EventBindings>
                <telerik:EventBinding Command="{Binding CustomCommand}"
                                      EventName="Close"
                                      PassEventArgsToCommand="True"/>
            </telerik:EventToCommandBehavior.EventBindings>
             ...
        </telerik:RadDocking>
    </Grid>
</Window>

Hope this is helpful.

Regards,
Vladi
Telerik
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
Tags
Docking
Asked by
Marcel
Top achievements
Rank 1
Answers by
Vladi
Telerik team
Share this question
or