wpf - What's the best way to auto-scroll a list view to the last added item? -
I use ListView to show a list of errors in my application. This behavior behaves like an error list in Visual Studio and looks at all. I want to add auto-scrolling when the last error item is selected (like auto-scrolling the visual studio's log window when you insert the caret at the end).
A observable collection in the list of errors, which is preferred by ListView.ItemsSource :
public Supervision & lt; ErrorListItem & gt; item; ... MyListView.ItemsSource = _Items; I tried to auto-scroll in the, select a pain that the last item has been selected, select new line etc. This is particularly difficult because it seems that_Items_CollectionChangedevent handler, but because it is an event onItemsSourceand not on the actual < Code> ListViewItemsListViewItemsis not immediately created. I've been able to auto-scroll by delaying the call to set the last item selected:choose from void _Items_CollectionChanged (Object Sender, NotifyCollectionChangedEventArgs e) {// Set the last item for 'e' ... _ItemPendingToBeScrolled = newItemTo; Select ListView.SelectedItem = newItemTo; Dispatcher.BeginInvoke (DispatcherPriority.Background, (ThreadStart) representative {if (_ItemPendingToBeScrolled! = Null) {ListView.ScrollIntoView (_ItemPendingToBeScrolled); ItemPendingToBeScrolled = null;}}}}but it is clear It is not the right way to do this. Also, I want to keep things working if the list is filtered (my source is not checking the last item, but
ListViewItemInListView).There is no way to listen to events when a
ListViewItemAfter an addition of Bound Collection, is added toListView? This would be an ideal event for capturing my auto-scrolling properly or could I use another technique
I have listboxes / list views and their scrolling, however, Hooking is mentioned, this is because you can see things Can not hear events with live storage? ObservableCollection list is much more stable than control, and you will receive the same notifications.
You can also bubble these incidents if it is not working in UI and you do not have access, in this way you use your scrolling in the UI without access to the actual archive , Just keep a reference in your custom eventArgse class selected items
Comments
Post a Comment