Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF ListView Always focused last added item?

Tags:

listview

wpf

I have many ListViews with the same DataSource with IsSynchronizedWithCurrentItem="True" and I'm dynamicaly adding items to this DataSource.

The problem ist when the scrolls appears, the added items are not visible unless I move the scrollbar. Should I use another Control for this purpose.. or how can bring the last added item into view (and scrollbars).

Until now I was doing everything directly in XAML, so I'd appreciate such a solution if possible.

like image 321
theSpyCry Avatar asked Oct 16 '09 07:10

theSpyCry


2 Answers

if ( !(myListView.Items.IsEmpty) )
{
    myListView.ScrollIntoView(myListView.Items[myListView.Items.Count - 1]);
}

Hope that helps!

like image 136
Amsakanna Avatar answered Oct 04 '22 22:10

Amsakanna


I think you may need to use the method:

ListView.ScrollIntoView(ListView.SelectedItem);
like image 24
Sam Meldrum Avatar answered Oct 04 '22 22:10

Sam Meldrum