C# CollectionViewSource CurrentChanged未触发

C# CollectionViewSource CurrentChanged未触发,c#,wpf,collectionviewsource,C#,Wpf,Collectionviewsource,我想知道我是否做错了什么?我的CurrentChanged似乎没有触发。它仅在应用程序启动时触发 ListItems = new ObservableCollection<string>(); ListItems.Add("hello"); ListItems.Add("world"); ListItems.Add("foo"); ListItems.Add("bar"); ListItems.Add("baz"); viewSource = CollectionViewSource

我想知道我是否做错了什么?我的CurrentChanged似乎没有触发。它仅在应用程序启动时触发

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);
};
ListItems=新的ObservableCollection();
添加(“你好”);
列表项。添加(“世界”);
列表项。添加(“foo”);
列表项。添加(“栏”);
列表项。添加(“baz”);
viewSource=CollectionViewSource.GetDefaultView(列表项);
viewSource.CurrentChanged+=(o,e)=>
{
MessageBox.Show((字符串)viewSource.CurrentItem);
};

哦,我发现了问题所在。我必须设置
IsSynchronizedWithCurrentItem=“True”

这对我来说很好,您在哪里更改列表?我发现了问题。我必须设置
IsSynchronizedWithCurrentItem=“True”
。无论如何,谢谢你:)