Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>As Simon said, it's the ScrollViewer in the standard ListBox template that's catching the event. To bypass it you can provide your own template.</p> <pre><code>&lt;ControlTemplate x:Key="NoWheelScrollListBoxTemplate" TargetType="ListBox"&gt; &lt;Border BorderThickness="{TemplateBinding Border.BorderThickness}" Padding="1,1,1,1" BorderBrush="{TemplateBinding Border.BorderBrush}" Background="{TemplateBinding Panel.Background}" Name="Bd" SnapsToDevicePixels="True"&gt; &lt;!-- This is the new control --&gt; &lt;l:NoWheelScrollViewer Padding="{TemplateBinding Control.Padding}" Focusable="False"&gt; &lt;ItemsPresenter SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}" /&gt; &lt;/l:NoWheelScrollViewer&gt; &lt;/Border&gt; &lt;ControlTemplate.Triggers&gt; &lt;Trigger Property="UIElement.IsEnabled" Value="False"&gt; &lt;Setter TargetName="Bd" Property="Panel.Background" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" /&gt; &lt;/Trigger&gt; &lt;Trigger Property="ItemsControl.IsGrouping" Value="True"&gt; &lt;Setter Property="ScrollViewer.CanContentScroll" Value="False" /&gt; &lt;/Trigger&gt; &lt;/ControlTemplate.Triggers&gt; &lt;/ControlTemplate&gt; </code></pre> <p>And the implementation for NoWheelScrollViewer is pretty simple.</p> <pre><code>public class NoWheelScrollViewer : ScrollViewer { protected override void OnMouseWheel(MouseWheelEventArgs e) { // Do nothing } } </code></pre> <p>Then, whenever you want a listbox to not handle the mouse wheel.</p> <pre><code>&lt;ListBox Template="{StaticResource NoWheelScrollListBoxTemplate}"&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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