This is a migrated thread and some comments may be shown as answers.

"Element is already the child of another element" error with DataPager

1 Answer 58 Views
DataPager
This is a migrated thread and some comments may be shown as answers.
Scott
Top achievements
Rank 1
Scott asked on 26 Apr 2011, 02:01 AM
Greetings.

I'm using a Dataform (really need full annotations support in your RadDataForm!) with a RadGridView & RadDataPager in an Mvvm Light application. The DataForm/RadGridView/RadDataPager are all bound to a QueryableCollectionView sitting in my ViewModel, and my DataPager PageSize property is set to 10.

If my collection has <10 items, I have no problem adding a new item to the collection. However, once I get to 10 items, then click the + sign in my dataform to add a new item, I get the following error:

Error: Unhandled Error in Silverlight Application
Code: 4009   
Category: ManagedRuntimeError      
Message: Element is already the child of another element.    

I tried binding an EventToCommand on the BeginningEdit event, and adjusting the page size accordingly, but that command never triggers. I'm rather at a loss on how else to proceed.

I have a sample project already created that demonstrates this, but I'm not able to attach the file. If you have any repository I can post/email into, I'm happy to do so.

Thanks for your help!

Scott

1 Answer, 1 is accepted

Sort by
0
Scott
Top achievements
Rank 1
answered on 27 Apr 2011, 01:20 AM
Solution to this turned out to be quite simple. I used EventToCommand to fire a command off on AddingNewItem (obviously not BeginningEdit, mispost). I then simply enter MyQueryableCollectionView.MoveToLastPage(). Boom. Done. Good game, thanks for playing.

Simplest of solutions...
Tags
DataPager
Asked by
Scott
Top achievements
Rank 1
Answers by
Scott
Top achievements
Rank 1
Share this question
or