Hello,
I'm useing RadTreeListView and have bound an ObservableCollection of TypeA to ItemsSource.
When I add first item of TypeB (derived from TypeA) to collection, then expand node and try to add second item of TypeA to collection I get error "unable to cast object of type TypeA to type TypeB.
I know that when node is not expanded, it's item container doesn't exist and there is no problem adding object of different types (derived from same type) to collection. On the other hand when the node is expanded, it's item container doesn't store items of same type as bound collection but items of type which is actual in bound collection. In my example TypeB, so you can't add items of TypeA due to cast issue.
Temporarily I just collapse node, add item, then expand node again. For me it isn't elegant solution, but maybe I'm wrong.
Is it a know problem/bug for you? How should I deal with it properly?
--
Szymon Wesolowski
I'm useing RadTreeListView and have bound an ObservableCollection of TypeA to ItemsSource.
<
telerik:RadTreeListView.ChildTableDefinitions
>
<
telerik:TreeListViewTableDefinition
ItemsSource
=
"{Binding Children }"
/>
</
telerik:RadTreeListView.ChildTableDefinitions
>
When I add first item of TypeB (derived from TypeA) to collection, then expand node and try to add second item of TypeA to collection I get error "unable to cast object of type TypeA to type TypeB.
I know that when node is not expanded, it's item container doesn't exist and there is no problem adding object of different types (derived from same type) to collection. On the other hand when the node is expanded, it's item container doesn't store items of same type as bound collection but items of type which is actual in bound collection. In my example TypeB, so you can't add items of TypeA due to cast issue.
Temporarily I just collapse node, add item, then expand node again. For me it isn't elegant solution, but maybe I'm wrong.
Is it a know problem/bug for you? How should I deal with it properly?
--
Szymon Wesolowski