views:

318

answers:

1

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 .

A: 

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

Thomas Levesque
Hi Thomas, that was one of the things I tried. I can't believe this is so difficult. Deleting and Editing is so easy. Even adding a new record is easy as long as you don't need to focus on it (Which is essential!) . I can't say to my clients that they have to go and find the inserted record before they can enter the new data, it should go there automatically. Thanks for your suggestion though..
Mitch
UPDATE! Solved, it turns out to be a potential problem/difference between ListCollectionView and the Xceed DataGridCollectionView. The DataGridCollectionView is supposed to be used in place of the ListCollectionView when using the Xceed DataGrid as it offers extra functionality. It seems that when my view was bound to the DataGridCollectionView, the AddNew no longer worked correctly, but as it was supposed to be a direct replacement for ListCollectionView I assumed the problem was with something I had done wrong. I'm going to contact Xceed now and get their "view" on this...
Mitch