开发者

CollectionViewSource CurrentChanged not triggering

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);
};


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜