How to know if Close comes from RadPane or RadPaneGroup

485 views Asked by At

We have following Raddocking declared:

<telerik:RadDocking 
        x:Name="RadDocking" 
        RetainPaneSizeMode="DockingAndFloating" 
        Close="RadDocking_OnClose" 
        CloseButtonPosition="InPaneAndGroup"
        HorizontalContentAlignment="Stretch"
        VerticalContentAlignment="Stretch"
        Loaded="RadDocking_OnLoaded"
        Visibility="{Binding IsMenuLoaded, Converter={StaticResource BooleanToVisibilityConverter}}">
        <telerik:RadDocking.DocumentHost>
            <telerik:RadSplitContainer>
                <telerik:RadPaneGroup prism:RegionManager.RegionName="MainRegion" DropDownDisplayMode="WhenNeeded">
                </telerik:RadPaneGroup>
            </telerik:RadSplitContainer>
        </telerik:RadDocking.DocumentHost>
</telerik:RadDocking>

As you can see we use the CloseButtonPosition InPaneAndGroup. And we implement our own logic on the Close event. But I want to check if we clicked on the close button in the pane, or on the close button of the group. Is there a way to know this? I've checked the Sender & StateChangedeventArgs, but they seem always only to hold 1 pane (the one that is active). But I would really need to know if it is the groupbutton or panebutton which is pressed, because we will handle other logic. Anyone any thoughts?

1

There are 1 answers

0
gogessj4 On BEST ANSWER

After some more looking around in the Telerik forum I found a solution that comes very close to what I need. Only a pity there is no build in solution for something like this. I can't imagine there is no need to a close all functionality and close tab functionality on the same time.

That said here is the source I based my solution on: Determine Source of Close

Here is the solution I made up:

First I implemented the logic mentioned in above link to the Preview on closing to set a flag that signifies that the group button was clicked or not:

    private void RadDocking_OnPreviewClose(object sender, StateChangeEventArgs e)
    {
        RadPane pane = e.Panes.ToList()[0];
        Point pt = Mouse.GetPosition(pane);
        if (pt.X <= pane.ActualWidth)
        {
            _groupClosing = false;
        }
        else
        {
            _groupClosing = true;
        }
    }

After that I just check on the flag in the closing method to handle the different logics

    private void RadDocking_OnClose(object sender, StateChangeEventArgs e)
    {
        if (!_groupClosing)
        {
            _regionManager.GetRegion(Constants.MainRegion).Remove(e.Panes.First().Content);
        }
        else
        {
            _regionManager.GetRegion(Constants.MainRegion).RemoveAll();
        }
    }

Hope this will help others in their quest for a similar problem.