ListCollectionView moving to newly created record

2019-06-10 04:21发布

When using a ListCollectionView, how do I move focus to the newly created record? My declarations are

Public WithEvents Data As PersonList = PersonList.GetList()
Private MyView As New ListCollectionView(Data)
Private WithEvents _Person As Person

The code I use to insert a person is

    _Person = New Person("AAAA", 100)
    Data.Insert(0, _Person)

I've tried using MyView.MoveCurrentTo(Dunno what to put here) but nothing seems to work.

If I was working with the underlying ObservableCollection then I would go to index 0, but I can't rely on this as the ListCollectionView can be sorted and filtered so the records are no longer in the same order as the ObservableCollection .

1条回答
仙女界的扛把子
2楼-- · 2019-06-10 04:58

Have you tried that ?

MyView.MoveCurrentTo(MyView.CurrentAddItem)

You could also use MyView.AddNew to add the new item, I suspect it makes it the current item.

Also, don't forget to set IsSynchronizedWithCurrentItem to True on your ItemsControl

查看更多
登录 后发表回答