Gepro
Gepro

Reputation: 583

Lock the scrolling in a ScrollViewer?

How can I lock vertical scrolling of a ScrollViewer by using the mouse wheel ?

Upvotes: 0

Views: 1445

Answers (1)

Mart
Mart

Reputation: 5788

If I understood you well, you wish to be able to scroll using the vertical scroll bar but not using the mouse wheel.

In this case just catch the mouse wheel event on your ScrollViewer content and mark it as handled:

<ScrollViewer>
    <StackPanel MouseWheel="MyContent_MouseWheel">
        ...
    </StackPanel>
</ScrollViewer>

and in code behind:

private void MyContent_MouseWheel(object sender, MouseWheelEventArgs e)
{
    e.Handled = true;
}

Upvotes: 2

Related Questions