I am using ObservableCollection as an ItemSource for my listBox component:
But the behavior of the control is not proper as for me. The matter I have scroll down to ths first occurence in my collection, but not last.
The sample list is: 1,1,2,3,4,5,6,7,8,9,11,22,33,1
When you enetr last 1 you component scroll up to first 1 :). This not what I am wating for.
Please advise. Here a code of component:
public class MyListBox : ListBox
{
protected override void OnItemsChanged(System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
{
base.OnItemsChanged(e);
if (Items.Count > 0)
{
var item = Items[Items.Count - 1];
UpdateLayout();
ScrollIntoView(item);
UpdateLayout();
}
}
}
Sorry but it needs to be a class as a List or OC is going to really do a value comparison. So you need to make identical values unique. I test this out and it works.