This question is locked. New answers and comments are not allowed.
Hi.
We want to populate our grid with data that contains custom collections implementing
INotifyCollectionChanged, IList<object>
It tests fine for all conditions and for example this works just as expected
However, when I stick our data ObservableCollection<ConjoinedCollection> into GridView I get the following exception for every visible index (column):
Lastly, If I process our ObservableCollection<OurCustomCollection> as follows (i.e. convert it into an ObservableCollection<ObservableCollection<object>>, it works.
Any idea what is going on here and how to fix this without re-wrapping the data?
Thanks!
We want to populate our grid with data that contains custom collections implementing
INotifyCollectionChanged, IList<object>
It tests fine for all conditions and for example this works just as expected
var cA = new ObservableCollection<object> {1, 2, 3, "A", "B", "C", null}; var cB = new ObservableCollection<object> { 10, 20, 30, "AA", "BB", "CC", null }; var collection = new ConjoinedCollection(cA, cB); var combo = new ComboBox {ItemsSource = collection};
However, when I stick our data ObservableCollection<ConjoinedCollection> into GridView I get the following exception for every visible index (column):
System.Windows.Data Error: Failed to connect to index '2' in object 'Commons.Model.Collections.ConjoinedCollection`1[System.Object]' (type 'Commons.Model.Collections.ConjoinedCollection`1[System.Object]'). BindingExpression: Path='[2]' DataItem='Commons.Model.Collections.ConjoinedCollection`1[System.Object]' (HashCode=16028238); target element is 'Telerik.Windows.Controls.GridViewBoundColumnBase+ValueSetter' (Name=''); target property is 'Value' (type 'System.Object').
Lastly, If I process our ObservableCollection<OurCustomCollection> as follows (i.e. convert it into an ObservableCollection<ObservableCollection<object>>, it works.
var viewData = new ObservableCollection<ObservableCollection<object>> (); foreach (var row in _viewModel.Data) // iterate through OC<CustomCollection> viewData.Add(new ObservableCollection<object>(row)); tkGrid.ItemsSource = viewData;
Any idea what is going on here and how to fix this without re-wrapping the data?
Thanks!