wpf – xaml Scrollviewer – 禁用整个窗口的过度滚动/橡皮筋效果/快照效果/弹跳
发布时间:2020-09-18 22:45:53 所属栏目:Windows 来源:互联网
导读:当我在列表框中使用滚动查看器时,当我通过触摸滚动到达列表框的末尾时,我的整个窗口都会弹跳.使用鼠标滚轮时不会出现此问题.如何禁用这种过度滚动/橡皮筋效果/反弹效果/弹跳效果. 我在Windows 8计算机上使用.NET Framework 4.5. 您可以在此视频中看到退回效果
当我在列表框中使用滚动查看器时,当我通过触摸滚动到达列表框的末尾时,我的整个窗口都会弹跳.使用鼠标滚轮时不会出现此问题.如何禁用这种过度滚动/橡皮筋效果/反弹效果/弹跳效果. 我在Windows 8计算机上使用.NET Framework 4.5. 您可以在此视频中看到退回效果:http://www.vidup.de/v/gQ2pI/ 这是我的示例代码: <Window x:Class="style_test_for_scrollviewer.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"> <Grid> <ListBox Width="200"> <WrapPanel Width="200" ScrollViewer.PanningMode="VerticalOnly" ScrollViewer.CanContentScroll="True" ScrollViewer.VerticalScrollBarVisibility="Visible"> <Button Height="200" Width="200"></Button> <Button Height="200" Width="200"></Button> <Button Height="200" Width="200"></Button> <Button Height="200" Width="200"></Button> <Button Height="200" Width="200"></Button> <Button Height="200" Width="200"></Button> <Button Height="200" Width="200"></Button> <Button Height="200" Width="200"></Button> <Button Height="200" Width="200"></Button> <Button Height="200" Width="200"></Button> <Button Height="200" Width="200"></Button> <Button Height="200" Width="200"></Button> </WrapPanel> </ListBox> </Grid> </Window>您可以通过重写OnManipulationBoundaryFeedback方法来删除此行为: public class FixedListBox : ListBox { protected override void OnManipulationBoundaryFeedback(ManipulationBoundaryFeedbackEventArgs e) { e.Handled = true; } } 另一种解决方案是将以下处理程序添加到ManipulationBoundaryFeedback事件(直接在ListBox上或通过样式): <ListBox ManipulationBoundaryFeedback="OnManipulationBoundaryFeedback"/> 要么: <Style TargetType="{x:Type ListBox}"> <EventSetter Event="ManipulationBoundaryFeedback" Handler="OnManipulationBoundaryFeedback"/> </Style> 使用以下代码: protected void OnManipulationBoundaryFeedback(object sender,ManipulationBoundaryFeedbackEventArgs e) { e.Handled = true; } 这些方法也适用于ScrollViewer. (编辑:大庆站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- windows下搭建Kafka运行环境
- xaml – 在开发Windows 8 Store应用程序时处理不同的方向
- winapi – Windows SDK 7.0的signtool中的signwizard发生了
- 本地windows上安装protobuf和thrit环境
- 老机器XP Outlook Express 发大附件对方客户端收到解压失败
- Windows – 如何使输出显示在Visual Studio 2005的错误列表
- .net – 加载Azure Storage 2.0时出错 – 无法加载Microsof
- libglog.dll CMake 在Windows上编译、应用glog
- win10安装scala-2.12.6.msi
- .net – WiX:Windows启动时如何注册应用程序启动?