0

I've created a listview in WPF. The items in there are changing their backgroundcolor by clicking, in this case i deactivated the listview prop 'Focusable'. For my usecase (on a touchscreen) i want to hide the scrollbar and just scroll by clicking an up/down button at the bottom. One click should scroll the whole page (UP/DOWN) and show the next (so far hided) items. I'm seraching for a flexible solution and don't want to calculate pixels or smth like that (also the items haven't a fixed height, also the window)

Thanks in advance

1 Answers1

0

First off, it might benefit you to take a look at How do I ask a good question?. Specifically, in your case it would be easier to understand the sitution if you included some of your XAML. However, I do think I have a solution for you.

ItemsControls like the ListView support "content scrolling", meaning the ability to scroll by content/items instead of by pixel. This question gives a solution to finding which items are currently visible in the ListView by accessing the internal ScrollViewer. ScrollViewer.VerticalOffset will tell you the index first visible item and ScrollViewer.ViewportHeight will tell you how many items are visible. To scroll to the "next page", you should just need to:

ScrollViewer.VerticalOffset += ScrollViewer.ViewportHeight;
Keith Stein
  • 6,235
  • 4
  • 17
  • 36