Skip to content

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

@martinskuta

Description

@martinskuta

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions