views:

16

answers:

1

I wonder if I am doing something wrong? My CurrentChanged does not seem to trigger. It only triggers on application start

ListItems = new ObservableCollection<string>();
ListItems.Add("hello");
ListItems.Add("world");
ListItems.Add("foo");
ListItems.Add("bar");
ListItems.Add("baz");
viewSource = CollectionViewSource.GetDefaultView(ListItems);
viewSource.CurrentChanged += (o, e) =>
{
    MessageBox.Show((string)viewSource.CurrentItem);
};
A: 

Oh I found out the problem. I must set IsSynchronizedWithCurrentItem="True"

jiewmeng