简体   繁体   English

在WPF中使用单独的ScrollViewer控制ListView

[英]Control ListView with separate ScrollViewer in WPF

I was searching for a way in WPF to create a scrollviewer (scrollbar) to control a ListView. 我正在WPF中寻找一种创建滚动查看器(滚动条)来控制ListView的方法。 Basically i want to disable the default scrollbar of the listview and show the scrollbar on a different panel. 基本上我想禁用默认的列表视图滚动条,并在其他面板上显示滚动条。

Can somebody point me in the right direction or provide me a code-snippet? 有人可以指出我正确的方向还是提供代码片段?

Thanks in advance. 提前致谢。

Edit: To make the explanation easier: 编辑:为了使说明更容易:

I would like to have a Window that contains a listview without a scrollbar and i would like a separate scrollbar on the screen that controls that listview. 我希望有一个包含列表视图的窗口,但没有滚动条,并且我想在控制该列表视图的屏幕上使用单独的滚动条。

If you want to have ListView in an panel without ScrollBars then simply disable them like this: 如果要在没有ScrollBar的面板中使用ListView,则只需禁用它们,如下所示:

<ListView ScrollViewer.VerticalScrollBarVisibility="Hidden"
          ScrollViewer.HorizontalScrollBarVisibility="Hidden" .../>

http://msdn.microsoft.com/en-us/library/system.windows.controls.scrollviewer.horizontalscrollbarvisibility(v=vs.110).aspx http://msdn.microsoft.com/zh-cn/library/system.windows.controls.scrollviewer.horizo​​ntalscrollbarvisibility(v=vs.110).aspx

http://msdn.microsoft.com/en-us/library/system.windows.controls.scrollviewer.verticalscrollbarvisibility(v=vs.110).aspx http://msdn.microsoft.com/zh-CN/library/system.windows.controls.scrollviewer.verticalscrollbarvisibility(v=vs.110).aspx

If you wish to have a separate ScrollViewer that will do the scrolling in ListView then Binding the properties of that ScrollViewer with the ScrollViewer in ListView. 如果希望有一个单独的ScrollViewer,它将在ListView中进行滚动,则将该ScrollViewer的属性与ListView中的ScrollViewer绑定。

Or you could move the ScrollViewer inside ListView by using ScrollToVertialOffset or ScrollToHorizontalOffset. 或者,您可以使用ScrollToVertialOffset或ScrollToHorizo​​ntalOffset在ListView中移动ScrollViewer。

http://msdn.microsoft.com/en-us/library/system.windows.controls.scrollviewer.scrolltoverticaloffset(v=vs.110).aspx http://msdn.microsoft.com/zh-cn/library/system.windows.controls.scrollviewer.scrolltoverticaloffset(v=vs.110).aspx

http://msdn.microsoft.com/en-us/library/system.windows.controls.scrollviewer.scrolltohorizontaloffset(v=vs.110).aspx http://msdn.microsoft.com/zh-CN/library/system.windows.controls.scrollviewer.scrolltohorizo​​ntaloffset(v=vs.110).aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM