开发者

CollectionViewSource CurrentChanged not triggering

开发者 https://www.devze.com 2023-01-20 06:05 出处:网络
I wonder if I am doing something wrong? My CurrentChanged does not seem to trigger. It only triggers on application start

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

精彩评论

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