Windows 10 UWP app c# - 禁用组合框中的鼠标滚轮

时间:2015-10-05 21:07:22

标签: c# xaml uwp

如何在组合框控制中禁用鼠标滚轮?

<ComboBox x:Name="ListDates" SelectedValuePath="Tag" Width="185" Background="#FFFFCC00" BorderThickness="1" Margin="12,8,0,0"/>

2 个答案:

答案 0 :(得分:2)

If you must do that, it's pretty simple - just disable vertical scrolling on the inner ScrollViewer.

<ComboBox x:Name="ListDates" 
          ScrollViewer.VerticalScrollMode="Disabled" 

答案 1 :(得分:2)

这个解决方案很冗长但有效。创建你的组合框类并用空处理程序覆盖OnPointerWheelChanged

public class ComboBoxNoWheel: ComboBox
{
    protected override void OnPointerWheelChanged(PointerRoutedEventArgs e)
    {

    }
}

您可以添加e.handled = true,但这与我的测试没有任何区别。组合框打开时滚动效果很好。