Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
285
Using mousewheel to scroll through xamTabControl tabs
posted

Hi!  I have an application with dynamic vertical tabs in a xamTabControl.  Each tab has its own tabs and content inside it.  Is there a way I can make the mousewheel scroll through the vertical tabs within the xamTabControl?  My end users had an application that allowed this type of scrolling and they are very used to using their mousewheel to scroll through the dynamic tabs quickly.  This was achieved in the old Win Forms application with a ToolStrip.  Thank you!

Parents
No Data
Reply
  • 6365
    Offline posted

    Hello Alicia,

    In order to use the mouse wheel for scrolling through the tab items of the XamTabControl, an approach I can suggest you is to handle the MouseWheel event by changing the SelectedIndex property of the XamTabControl depending on the Delta value (indicates if the user is scrolling up or down) of the MouseWheelEventArgs instance.

    private void xtc_MouseWheel(object sender, MouseWheelEventArgs e)
    {
        var scrollAmount = e.Delta;
        var tabControl = (sender as XamTabControl);
        var selectedTabIndex = tabControl.SelectedIndex;

        if ((selectedTabIndex == tabControl.Items.Count - 1 && scrollAmount < 0) ||
            (selectedTabIndex == 0 && scrollAmount > 0))
            return;

        if (scrollAmount < 0)
            tabControl.SelectedIndex = selectedTabIndex + 1;
        else
            tabControl.SelectedIndex = selectedTabIndex - 1;
    }

    I have attached a sample application, where the approach from above has been used.
    If you require any further assistance on this matter, please do not hesitate to ask.
     

    XamTabControl_mouseWheelScrolling.zip
Children
No Data