I'm currently working on an application using WPF. And I can't but help to notice the difference in ScrollViewer functionality compared to the Windows Store App variant.
When I'm at the edge of the screen and the edge of a ScrollViewer and I want to slide so that I'd move away from the edge. I see the windows desktop or menubar (when at the bottom of the screen). Is there a solution to prevent this scroll behaviour from happening? It is rather annoying (and ugly!) when your scrolling till the edge of the screen and then get bumped back and see a bit of the windows platform underneath. This behaviour is fixed in the Windows Store App ScrollViewer..
I tried overwriting the ScrollChanged
and checking if f.e. horizontalOffset == 0 && horizontalChange < 0
and return if this is the case. But this check doesn't seem to work (since then it's probably already too late).
And I can't seem to find the way Windows Store Apps have fixed this.
Perhaps you guys have an idea?
EDIT: Reproduction for WPF projects in .NET 4.5.1
This piece of XAML re-creates my problem in WPF. However in Windows Store App the problem doesn't seem to exist.
How can I prevent this behaviour when scrolling to and/or over the edges of my application?
<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525" ResizeMode="NoResize" WindowState="Maximized" WindowStyle="None">
<Grid>
<ScrollViewer HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden" PanningMode="Both">
<Rectangle Height="2500" Stroke="Black" Width="3500" HorizontalAlignment="Left" VerticalAlignment="Top">
<Rectangle.Fill>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0,0.5">
<GradientStop Color="#FF00FF68" Offset="0"/>
<GradientStop Color="Red" Offset="1"/>
<GradientStop Color="#FF95FF00" Offset="0.506"/>
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
</ScrollViewer>
</Grid>
</Window>