Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Annoying auto scroll of partially displayed items in WPF ListView

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

like image 308
AVEbrahimi Avatar asked Oct 17 '12 06:10

AVEbrahimi


1 Answers

had the same problem and i've found a sulotion :)

in the Xaml you define a style for the ListViewItem with this EventSetter:

<ListView.ItemContainerStyle>
    <Style TargetType="{x:Type ListViewItem}">
         <EventSetter Event="RequestBringIntoView" Handler="ProjectListView_OnRequestBringIntoView"/>
    </Style>
</ListView.ItemContainerStyle>

in code behind:

private void ProjectListView_OnRequestBringIntoView(object sender, RequestBringIntoViewEventArgs e)
{
    e.Handled = true;
}

Hope this will work for you too :)

like image 50
user3379493 Avatar answered Sep 22 '22 22:09

user3379493