As I scroll up or down the ListView, I would like the ListView to only scroll entire ListViewItems into the view instead of smoothly scrolling. Basically the ListView will never PARTIALLY show an item in the ListView. How do I achieve this?
Asked
Active
Viewed 116 times
0
-
This question asks the opposite, see if the answers might be helpful: https://stackoverflow.com/questions/1033841/is-it-possible-to-implement-smooth-scroll-in-a-wpf-listview – vesan Jun 14 '18 at 02:59
-
1You could override the scroll event and do some math to work out where the ListView should be scrolled to and then manually set it to that position and consume the scroll event. – sorifiend Jun 14 '18 at 04:23
-
1In order to begin to provide a solution, you would need to assume that all the items are the same height and the height of the container was a multiple of that; adjusted for the margins of items, and the padding of the container, etc. If that sounds a reasonable assumption then a `Behavior
`, hooking into the scroll events would seem a likely solution. – Richardissimo Jun 14 '18 at 05:21 -
1What the guy above me said, but also make sure you set `CanContentScroll=True` – TomerAgmon1 Jun 14 '18 at 07:23
-
1In WPF, you can set the `VirtualizingPanel.ScrollUnit` attached property to `Item`. – mm8 Jun 14 '18 at 13:17
-
Thanks for replies. Oh, and I am developing a UWP app, if that matters. – LeBrown Jones Jun 14 '18 at 14:34
-
ListView is for displaying data items in a vertical stack. Generally, it will display many items in the view, if you want never PARTIALLY show an item, why not use the [FlipView](https://learn.microsoft.com/en-us/windows/uwp/design/controls-and-patterns/flipview)? – Breeze Liu - MSFT Jun 15 '18 at 09:45
-
I guess you mean a heavily customized FlipView that displays its data EXACTLY like a ListView? I guess it is worth seeing if it works. Thanks for the reply, though. – LeBrown Jones Jun 15 '18 at 15:11
-
Do you have a try to make it works from custom the FlipView? Whether it satisfy your reqirement? – Breeze Liu - MSFT Jun 20 '18 at 07:04
1 Answers
0
Please look on ScrollViewer.CanContentScroll
property, set it to false
or true
(depending on what you need):
<ListView ItemsSource="{Binding Items}" ScrollViewer.CanContentScroll="False"/>

Gabriel
- 377
- 1
- 3
- 15