Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Insert to ObservableCollection<ObservableCollection<T>> set as RowSource throws #34

Open
martinskuta opened this issue Jun 25, 2018 · 1 comment

Comments

@martinskuta
Copy link

martinskuta commented Jun 25, 2018

Hey,

started playing around with your extensions as I am building simple table designer control in WPF and your library is a good kickstarter as we can use really tabular items source (collection of collections). Really cool, thank you for that!

I was working on a POC where I was implementing drag/drop reorder of columns and rows and realized that your extension has a bug when inserting a row to different index than the last index (simple add). If you insert a row to the ObservableCollection bound as RowSource to index 0, ListCollectionView will throw InvalidOperationException.

You can reproduce it easily in your Demo project by changing this line to this.Data.Insert(0, new ObservableCollection<int>(newRow)); instead of Add and then on second call it will fail.

The exception is thrown because the List2DView doesn't actually insert the row internally, but adds it to the end. I had a quick look and the root cause is this line where you should call this.Rows.Insert(index, listRowView); instead of this.Rows.Add(listRowView);. I think the fix will be bit more difficult, because indexes of ListRowViews following the insertion need to be updated, which is not possible at the moment as they are only readonly properties and also the property list index descriptors I believe, so it seems also like architectural change.

Do you see a simple way of fixing it?

@JohanLarsson
Copy link
Member

Thanks for reporting!
I'll have a look, the internals are a bit messy here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants