我目前正在使用WPF开发应用程序.而且我不得不注意到与Windows Store App变体相比ScrollViewer功能的差异.
当我在屏幕的边缘和ScrollViewer的边缘时,我想要滑动,以便我离开边缘.我看到Windows桌面或菜单栏(在屏幕的底部).有没有解决方案来防止这种滚动行为发生?当你滚动到屏幕的边缘然后被撞回来看到下面的一些Windows平台时,它相当烦人(而且很丑!).Windows应用程序ScrollViewer中已修复此问题.
我尝试覆盖ScrollChanged
并检查fe horizontalOffset == 0 && horizontalChange < 0
是否返回,如果是这种情况.但这种检查似乎不起作用(从那以后它可能已经太晚了).而我似乎无法找到Windows应用商店应用程序修复此问题的方式.
也许你们有个主意吗?
编辑: .NET 4.5.1中的WPF项目的再现
这段XAML在WPF中重新创建了我的问题.但是,在Windows应用商店应用中,问题似乎不存在.
滚动到和/或覆盖应用程序边缘时,如何防止此行为?
<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>
Run Code Online (Sandbox Code Playgroud)