user3239349
user3239349

Reputation: 917

C# UWP Disable pointer wheel

In C# UWP app how to disable pointer wheel on scrollviewer, and still be able to move scroll with touch?

I have situation like this:

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

    <ListView/>

</ScrollViewer>

Any ideas?

Upvotes: 0

Views: 297

Answers (1)

Sean O&#39;Neil
Sean O&#39;Neil

Reputation: 1241

This in your code behind should override your mouse wheel input if you assign a focus condition.

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 }        
}

Upvotes: 1

Related Questions