I have a ListView in WPF, my problem is if an item is partially displayed and I click on item, the list will automatically scroll so the whole item will be visible.
How can I disable this Auto Scroll feature?
Thank you
I have a ListView in WPF, my problem is if an item is partially displayed and I click on item, the list will automatically scroll so the whole item will be visible.
How can I disable this Auto Scroll feature?
Thank you
The default behavior of ListView is call
BringIntoView()
after it was clicked. You can add an event handler toPreviewMouseDown
event and handle it by sete.Handled = true;
.Following Ekk's answer, you have to handle the bringIntoView event NOT on the parent listView but in the children event. In my peculiar case for example my listBox has some runtime-code create elements. Those can be basically stackpanel of textboxes or, at the end a stackpanel of buttons.
Despite the fact of how those are made I just have have added
to each of those and the effect was that, after clicking, they were not brought into view but the action associated with each of them was immediately executed.
I found a work around, my ListView is displaying Photo items in MVVM
had the same problem and i've found a sulotion :)
in the Xaml you define a style for the ListViewItem with this EventSetter:
in code behind:
Hope this will work for you too :)
Setting
ScrollViewer.VerticalScrollBarVisibility="Auto"
for the list view helped.