C#UWP禁用指针轮

时间:2017-11-20 12:15:30

标签: c# uwp gesture scrollviewer

在C#UWP应用程序中如何禁用滚动查看器上的指针轮,并且仍能够通过触摸移动滚动?

我有这样的情况:

<ScrollViewer 
    VerticalScrollMode="Disabled"
    VerticalScrollBarVisibility="Disabled"
    HorizontalScrollMode="Enabled"
    HorizontalScrollBarVisibility="Hidden"
    VerticalAlignment="Stretch"
    HorizontalAlignment="Stretch">

    <ListView/>

</ScrollViewer>

有什么想法吗?

1 个答案:

答案 0 :(得分:1)

如果您指定了焦点条件,则在您的代码后面应该覆盖您的鼠标滚轮输入。

public MyView()
{
     this.InitializeComponent();
     Window.Current.CoreWindow.PointerWheelChanged += CoreWindow_PointerWheelChanged;
}

private void CoreWindow_PointerWheelChanged(CoreWindow sender, PointerEventArgs args)
{
     if (!SomeConditionLikeYourScrollViewerIsFocused)
     {
        args.Handled = true;
     }
     else { // do nothing }        
}