当前位置:网站首页>wpf ScrowViewer水平滚动
wpf ScrowViewer水平滚动
2022-07-31 05:09:00 【JOJOL1N】
首先,设置正常的scrollViewer,里面套一个Grid
<ScrollViewer x:Name="sv"
HorizontalScrollBarVisibility="Hidden"
VerticalScrollBarVisibility="Hidden"
VerticalAlignment="Stretch"
HorizontalAlignment="Stretch"
Grid.Row="1"
Height="33"
Grid.Column="0" >
<Grid x:Name="appTabControl"
VerticalAlignment="Stretch" MouseWheel="appTabControl_MouseWheel"
Height="33"
>
</Grid>
</ScrollViewer>
然后,根据鼠标滚轮事件的delta参数来设置scrollViewer的ScrollToHorizontalOffset方法来进行移动,注意:鼠标滚轮事件必须是Grid的,如果是ScrollViewer的鼠标滚轮事件则无作用。
private void appTabControl_MouseWheel(object sender, MouseWheelEventArgs e)
{
//sv是scrollViewer
sv.ScrollToHorizontalOffset(-e.Delta);
}
参数e.Delta可以根据开发需要来设置正负号,进行滚轮方向的调整。
懒得弄gif,没有效果演示
边栏推荐
- 关于LocalDateTime的全局返回时间带“T“的时间格式处理
- Input length must be multiple of 8 when decrypting with padded cipher
- “档次法”——用于物品体积分布不均匀的01背包问题的求解方法
- Data set partitioning and cross-validation
- 目标检测学习笔记
- MySQL_关于JSON数据的查询
- 运用flask框架发送短信验证码的流程及具体代码
- Unity mobile game performance optimization series: performance tuning for the CPU side
- Flink sink redis 写入Redis
- 2022-07-30:以下go语言代码输出什么?A:[]byte{} []byte;B:[]byte{} []uint8;C:[]uint8{} []byte;D:[]uin8{} []uint8。
猜你喜欢
随机推荐
Linux系统安装mysql(rpm方式安装)
Why use Flink and how to get started with Flink?
Minio upload file ssl certificate is not trusted
MySQL-如何分库分表?一看就懂
Sword Point Offer Special Assault Edition ---- Day 2
分布式事务处理方案大 PK!
剑指offer基础版 ----- 第25天
With MVC, why DDD?
为什么要用Flink,怎么入门使用Flink?
Object Detection Study Notes
剑指offer基础版 ---- 第26天
MySQL8--Windows下使用压缩包安装的方法
Flask 的初识
剑指offer基础版 --- 第21天
Paginate the list collection and display the data on the page
数据库学习笔记
Anaconda configure environment directives
Redis Advanced - Cache Issues: Consistency, Penetration, Penetration, Avalanche, Pollution, etc.
目标检测学习笔记
torch.normal函数用法