I have a ListView that gets updated frequently, at irregular intervals.
I want it so that when an update is received the item will be scrolled into view.
I know the code to do that:
logListView.ScrollIntoView(logListView.Items[logListView.Items.Count - 1]);
I don't know where to put it so that it happens when the ListView is updated.
I've tried putting it in the LayoutUpdated
event handler of the ListView, but when I try to scroll during a period when there are no updates (I know there aren't any updates because I've turned the message pump off) the view is stuck at the bottom. I'm guessing this is because scrolling raises a LayoutUpdated
event.
How do I get the ListView to scroll to the bottom when it receives a new item?