I have a ScrollViewer around a Grid to vertically scroll it's content.
<ScrollViewer>
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
...
</Grid>
</ScrollViewer>
Inside of this Grid i have another Scrollviewer with horizontal content.
<Grid>
<ScrollViewer Name="ScrollViewer" VerticalScrollMode="Disabled" VerticalScrollBarVisibility="Disabled" HorizontalScrollMode="Disabled" HorizontalScrollBarVisibility="Hidden">
...
</ScrollViewer>
<Button Name="ButtonRight" HorizontalAlignment="Right" VerticalAlignment="Stretch" Tapped="ButtonRight_Tapped" />
<Button Name="ButtonLeft" HorizontalAlignment="Left" VerticalAlignment="Stretch" Tapped="ButtonLeft_Tapped" />
<Grid>
The HorizontalScrollMode
is disabled and HorizontalScrollBarVisibility
is hidden because with mouse input, i want to scroll the content with the left/right buttons. The HorizontalScrollMode
is disabled to prevent horizontal scrolling when the mouse is inside the ScrollViewer.
private void ButtonRight_Tapped(object sender, TappedRoutedEventArgs e)
{
ScrollViewer.ChangeView(ScrollViewer.HorizontalOffset + ScrollViewer.ActualWidth, 0, 1);
}
With this configuration i can scroll the page vertically even when the mouse is inside the horizontal ScrollViewer. Here is an image to give you an idea:
The problem is with touch. How can i still scroll horizontally when the user is using a touch device? When i enable
HorizontalScrollMode
touch works as desired, but with a mouse it scrolls horizontally which i try to prevent.
Is there a way to ignore the horizontal scrolling with nested ScrollViewers?
IsHorizontalScrollChainingEnabled
supposed to work? When i set it to false on the child scrollviewer there is no difference, horizontal scrolling is still enabled. – Thomas Schneiter<ScrollViewer IsHorizontalScrollChainingEnabled="False" ...>
. On what element should i put the attached property? – Thomas Schneiter