Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I use the MouseWheel event to scroll through the TabItems of nested TabControls?
    primarykey
    data
    text
    <p>I have a TabControl that can contain a TabControl in each TabItem. There is the xaml-code:</p> <pre><code>&lt;TabControl Height="300" Width="500" MouseWheel="TabControl_MouseWheel"&gt; &lt;TabItem Header="1" Width="50"&gt; &lt;TabControl MouseWheel="TabControl_MouseWheel"&gt; &lt;TabItem Header="1" Width="50"&gt;&lt;/TabItem&gt; &lt;TabItem Header="2" Width="50"&gt;&lt;/TabItem&gt; &lt;TabItem Header="3" Width="50"&gt;&lt;/TabItem&gt; &lt;TabItem Header="4" Width="50"&gt;&lt;/TabItem&gt; &lt;TabItem Header="5" Width="50"&gt;&lt;/TabItem&gt; &lt;TabItem Header="6" Width="50"&gt;&lt;/TabItem&gt; &lt;TabItem Header="7" Width="50"&gt;&lt;/TabItem&gt; &lt;TabItem Header="8" Width="50"&gt;&lt;/TabItem&gt; &lt;TabItem Header="9" Width="50"&gt;&lt;/TabItem&gt; &lt;/TabControl&gt; &lt;/TabItem&gt; &lt;TabItem Header="2" Width="50"&gt; &lt;TabControl MouseWheel="TabControl_MouseWheel"&gt; &lt;TabItem Header="1" Width="50"&gt;&lt;/TabItem&gt; &lt;TabItem Header="2" Width="50"&gt;&lt;/TabItem&gt; &lt;TabItem Header="3" Width="50"&gt;&lt;/TabItem&gt; &lt;TabItem Header="4" Width="50"&gt;&lt;/TabItem&gt; &lt;TabItem Header="5" Width="50"&gt;&lt;/TabItem&gt; &lt;TabItem Header="6" Width="50"&gt;&lt;/TabItem&gt; &lt;TabItem Header="7" Width="50"&gt;&lt;/TabItem&gt; &lt;TabItem Header="8" Width="50"&gt;&lt;/TabItem&gt; &lt;TabItem Header="9" Width="50"&gt;&lt;/TabItem&gt; &lt;/TabControl&gt; &lt;/TabItem&gt; &lt;TabItem Header="3" Width="50"&gt;&lt;/TabItem&gt; &lt;TabItem Header="4" Width="50"&gt;&lt;/TabItem&gt; &lt;TabItem Header="5" Width="50"&gt;&lt;/TabItem&gt; &lt;TabItem Header="6" Width="50"&gt;&lt;/TabItem&gt; &lt;TabItem Header="7" Width="50"&gt;&lt;/TabItem&gt; &lt;TabItem Header="8" Width="50"&gt;&lt;/TabItem&gt; &lt;TabItem Header="9" Width="50"&gt;&lt;/TabItem&gt; &lt;/TabControl&gt; </code></pre> <p>I want to change the selected item of tabcontrols by mouse wheeling. There is MouseWheel event handler:</p> <pre><code>private void TabControl_MouseWheel(object sender, MouseWheelEventArgs e) { TabControl tabControl = sender as TabControl; if (tabControl != null) { if (e.Delta &lt; 0) { if (tabControl.SelectedIndex + 1 &lt; tabControl.Items.Count) tabControl.SelectedItem = tabControl.Items[tabControl.SelectedIndex + 1]; } else { if (tabControl.SelectedIndex - 1 &gt; -1) tabControl.SelectedItem = tabControl.Items[tabControl.SelectedIndex - 1]; } } } </code></pre> <p>The problem is that scrolling with the mouse wheeling just changes the selected item in the upper TabControl. I want other TabControls to react to mouse wheeling too.</p> <p>For example: if the cursor is in one of the upper TabControl items then I want them to react to mouse wheel scrolling, otherwise I want the lower TabControls items to react to the scrolling.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload