RadDocking PreviewClose

4 posts, 0 answers
  1. Adrian
    Adrian avatar
    10 posts
    Member since:
    Jun 2013

    Posted 08 Nov 2013 Link to this post

    I have 2 questions about this event.

    1. How can I cancel pane closing in this event (or any other way)?
    2. What this event is designed for?

    Regards,
    Adrian
  2. Vladi
    Admin
    Vladi avatar
    744 posts

    Posted 13 Nov 2013 Link to this post

    Hi,

    The PreviewClose as any preview event in WPF is designed to trigger before the corresponding event is triggered. In order to cancel the closing of a Pane/PaneGroup in that event all you need to do is handle it by setting the Handled property of the StateChangeEventArgs to True. The next code snippet shows how to cancel the closing in the PreviewClose event:
    <telerik:RadDocking PreviewClose="RadDocking_PreviewClose">
        ...
    </telerik:RadDocking>

    and the event handler:
    private void RadDocking_PreviewClose(object sender, Telerik.Windows.Controls.Docking.StateChangeEventArgs e)
    {
        e.Handled = true;
    }

    Hope this is helpful.

    Regards,
    Vladi
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  3. UI for WPF is Visual Studio 2017 Ready
  4. Adrian
    Adrian avatar
    10 posts
    Member since:
    Jun 2013

    Posted 13 Nov 2013 Link to this post

    Thanks Vladi,

    I was looking for Cancel property because I thought that StateChangeEventArgs is a CancelEventArgs and I forgot about Handled. Other question I have is how to cancel closing only one pane if multiple pane are closed (e.g. when closing ToolWindow with few panes docked inside)?

    Regards,
    Adrian
  5. Vladi
    Admin
    Vladi avatar
    744 posts

    Posted 14 Nov 2013 Link to this post

    Hello,

    When closing multiple Panes at the same time the PreviewClose event will be triggered multiple times for each Pane. You could simply get the first element of the Panes collection from the StateChangeEventArgs which is the currently closing Pane and use that Pane's details to filter if it needs to be closed or not. The next code snippet shows how to filter the closing Pane and if its Header matches the condition it will not be closed:
    private void RadDocking_PreviewClose(object sender, Telerik.Windows.Controls.Docking.StateChangeEventArgs e)
    {
        var pane = e.Panes.First();
     
        if (pane.Header.ToString() == "Pane 1")
        {
            e.Handled = true;
        }
    }


    Regards,
    Vladi
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
Back to Top