wpf – xaml Scrollviewer – 禁用整个窗口的过度滚动/橡皮筋效果/快照效果/弹跳
发布时间:2020-09-05 22:46:25 所属栏目: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. (编辑:南阳站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- .net – 为什么我无法在2.0.0.0播放器框架中重用1.8.2.2 Pl
- 使用dll和java jni4net时出现UnsatisfiedLinkError异常
- 部署 – Windows 8 Simulator命令行界面
- windows – 为什么输出传输时某些“for”命令不起作用?
- windows下编译支持https的libcurl
- Windows Vista 64位的命令行subversion客户端
- 什么是“Microsoft C例外”?
- windows-phone-7 – Caliburn Micro中的墓碑
- 飞溅屏幕 – 通用窗口10个应用程序的Splash屏幕
- windows-8 – 地铁样式Windows 8应用程序是否支持本地数据库
推荐文章
站长推荐
- windows-runtime – 将Action绑定到XAML中UserCo
- 32位数据转8位数据和8位数据转32位数据
- windows-8 – 在MetroStyle应用程序中使用COM对象
- winforms – 在单元测试方法中显示Windows窗体
- windows – dokan sshfs有多稳定?
- xaml – Windows 8 App,更改BackButtonStyle的颜
- .net – 为什么我无法在2.0.0.0播放器框架中重用
- batch-file – 用于在Windows 7中更改屏幕分辨率
- .net – 适用于Windows 7.0的蓝牙低功耗API
- windows – 启动进程时“print”和“printo”动词
热点阅读
