0
votes

I was searching for a way in WPF to create a scrollviewer (scrollbar) to control a 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.

1
Why would you want to do that? Its is hard to provide you with anything since those few lines do not tell much. Do you have code you would like to share? Point us to a direction please. Give us more detail. Your question is too general :)dev hedgehog
Basically i want to create a Window with two panels. 1 of these panels will contain a listview and 1 panel will contain a scrollviewer. :-) it must be like this for designreasons, because a panel will overlap the position of the default scrollbar. And for the code.. just take a default listview for this.stackr

1 Answers

1
votes

If you want to have ListView in an panel without ScrollBars then simply disable them like this:

<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/en-us/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.

Or you could move the ScrollViewer inside ListView by using ScrollToVertialOffset or ScrollToHorizontalOffset.

http://msdn.microsoft.com/en-us/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