In order to add/remove items in a databound RadTreeView
, you need to bind its ItemsSource
to a collection that implements the INotifyCollectionChanged
interface. The ObservableCollection<T>
has a built-in implementation of a data collection that exposes the INotifyCollectionChanged
interface. However, your LINQ statement returns a collection that doesn't implement the interface. Therefore when you use a LINW to SQL
to set the RadTreeView ItemsSource
collection, the RadTreeView
control won't be notified if the collection is changed.
Basically the RadTreeView
control is a data-driven control. So the RadTreeViewItems add/remove operations are changing the underlying ItemsSource
collection in databound scenarios. Now, when you cannot notify the RadTreeView
that the collection is changed, the control won't be able to visually display those changes thus causing the issues you experienced.
In order to get over this behavior you can wrap the collection returned by the LINQ statement in an ObservableCollection
- you can try something like that:
var collection = linq_data_model.TreeItem.Where(w => w !=
&& w.parent_ID == 0 && w.ID != 0);
If this doesn't help it would be best to send us a small sample reproducing your scenario and the issue so that we can further examine the case.
All the best,
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>