radpane header mousewheel click ==> close

5 posts, 1 answers
  1. Labarque
    Labarque avatar
    10 posts
    Member since:
    Sep 2013

    Posted 31 Dec 2013 Link to this post

    Hello

    How can I implement the following behaviour?

    When a user clicks the header of a radpane with the mouse wheel then the radpane should close.

    (same behaviour when you click a tabheader in Internet Explorer)

    Thanks!

  2. Kalin
    Admin
    Kalin avatar
    1209 posts

    Posted 02 Jan 2014 Link to this post

    Hello Labarque,

    The desired scenario can be achieved by handling the MouseDown event of the main Border in the PaneHeaderTemplate. Inside of the handler you can easily get the clicked Pane and hide it. Please check the attached sample project which demonstrates the exact approach.

    Hope this helps. If you have any further questions, let us know.

    Regards,
    Kalin
    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. Labarque
    Labarque avatar
    10 posts
    Member since:
    Sep 2013

    Posted 02 Jan 2014 Link to this post

    Thank you Kalin for the reply.


    I do not get this working in the following scenario. Can you help me on this?
    Thanks!



    <telerik:RadDocking x:Name="Docking" >
        <telerik:RadDocking.DocumentHost >
            <telerik:RadSplitContainer >
                <telerik:RadPaneGroup>
                    <telerik:RadPane   Header="Pane 2" />
                </telerik:RadPaneGroup>
            </telerik:RadSplitContainer>
        </telerik:RadDocking.DocumentHost>
    </telerik:RadDocking>
  5. Answer
    Kalin
    Admin
    Kalin avatar
    1209 posts

    Posted 03 Jan 2014 Link to this post

    Hello Labarque,

    It is not working because the Pane uses different Templates for the different scenarios. In this case you would also need to extract the PaneDocumentHostTemplate and handle the MouseDown event of the Grid inside. However I can also suggest another solution in which you could simply handle the MouseDown event of the Docking and check inside for the clicked element as shown below:

    XAML:
    <telerik:RadDocking x:Name="Docking" MouseDown="OnMouseDownHandler">
        <telerik:RadDocking.DocumentHost >
            <telerik:RadSplitContainer>
                <telerik:RadPaneGroup>
                    <telerik:RadPane Header="Pane 1" />
                </telerik:RadPaneGroup>
            </telerik:RadSplitContainer>
        </telerik:RadDocking.DocumentHost>
        <telerik:RadSplitContainer InitialPosition="DockedRight">
            <telerik:RadPaneGroup>
                <telerik:RadPane Header="Pane 2" />
            </telerik:RadPaneGroup>
        </telerik:RadSplitContainer>
    </telerik:RadDocking>

    Code behind:
    private void OnMouseDownHandler(object sender, MouseButtonEventArgs e)
    {
        if (e.ChangedButton == MouseButton.Middle && e.ButtonState == MouseButtonState.Pressed)
        {
            var item = (FrameworkElement)e.OriginalSource;
            var pane = item.ParentOfType<RadPane>();
            if (pane != null)
            {
                (pane as RadPane).IsHidden = true;                   
            }
            else
            {
                var paneHeader = item.ParentOfType<PaneHeader>();
                if (paneHeader != null)
                {
                    (paneHeader.SelectedPane as RadPane).IsHidden = true;
                }
            }               
        }
    }

    Hope this works for you.

    Regards,
    Kalin
    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 >>
  6. Labarque
    Labarque avatar
    10 posts
    Member since:
    Sep 2013

    Posted 03 Jan 2014 Link to this post

    Super! This works perfectly for me.
    Thank you!
Back to Top
UI for WPF is Visual Studio 2017 Ready