List box starting at bottom
I am trying to display a command line history type box which pops upwards from an expander on the my "command line" element.
I am using a list box to show this command history, however since it is popping upwards, I would like to snap to the bottom entry of the list box when it is displayed from the expander, so the user sees the most recent entry. I can't see any easy property which allows me to manipulate this list box?!
Ideally it would be nice to stay at the bottom of the scroll box if it is visible when new items are added, but this is not absolutely necessary.
I should mention that the list box is bound to an observable collection in a clr class.
Thanks
You could add new entries to the beginning of your observable collection instead of the end:
collection.Insert(0, newItem);
This will display your history in reverse order (most recent first), but at least when you make it visible you'll see the most recent entry.
I appreciate both of these points, but the problem there would be that I would pop upwards a history which you would have to scroll downwards to see the items further in the past, which is not the most intuitive interface.
Is there an event I can use to tell if the collection in the list box has changed - source changed doesn't seem to work, and is there a reason why list box doesn't expose the lineup linedown events of the underlying scroll viewer, or more importantly - scrollToBottom?
I assume there is some way I can tap into these methods?