如何使用 ItemsControl 在 WPF 中创建内容旋转器/滑块?
我的目标是使用 WPF 创建一个内容滑块,类似于使用 JQuery 广泛使用的内容滑块。移动框脚本就是一个示例: 移动框
我一直在搜索,但是很难找到 WPF 有一个名为 Slider 的控件,而Rotator通常引用动画。我尝试在自定义动画滚动查看器中使用水平堆栈面板,但收效甚微。所以任何想法都会受到赞赏。
更新: 我能够通过创建自定义 ScrollViewer 控件来完成此功能,并添加依赖属性以通过事件启用滚动动画。我以这个项目为灵感:Animate WPF ScrollViewer on Codeplex
My goal is to create a content slider with WPF similar to what is widely available using JQuery. An example is the Moving boxes script:
Moving Boxes
I've been searching, but it's hard to find when WPF has a control called Slider, and Rotator is usually referencing animation. I've tried using a horizontal stackpanel inside of a custom animated scrollviewer to little success. So any ideas are appreciated.
UPDATE:
I was able to accomplish this functionality by creating a custom ScrollViewer control with dependency properties added to enable animation of the scrolling via events. I used this project as inspiration:Animate WPF ScrollViewer on Codeplex
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不久前做了类似的事情,但我没有再得到代码了。
我确信我在水平方向的堆栈面板上使用了列表视图,并且您可以隐藏滚动条,因此它看起来就像一个普通列表。
然后,您可以创建两个用于向左或向右滚动的控件,当按下其中一个时,只需调用 Listview 对象的scrollIntoView 方法。
希望这会有所帮助。
I done something similar to this a while ago but I haven't got the code anymore.
I am sure I used a listview on a stackpanel with horizontal orientation and you are able to hide the scroll bar so it just looks like a plain list.
You can then create two controls for scrolling left or right and when either is pressed just call the scrollIntoView method of the Listview object.
Hope this helps a bit.
这是有关该主题的链接 http://blog.pixelingene。 com/2008/06/a-carousel-view-for-elementflow/ 这是一个 3d 控件,但它可以给你一些想法
Here's a link on the subject http://blog.pixelingene.com/2008/06/a-carousel-view-for-elementflow/ it's a 3d control but it can give you some ideas