Declined
Last Updated: 11 Aug 2016 14:04 by ADMIN
ADMIN
Telerik Admin
Created on: 09 Mar 2011 11:13
Category: TreeView
Type: Bug Report
27
TreeView: Selection doesn't work correctly when equal objects are used in the source collection
When two equal objects are used in the source collection, the first is always selected when you try to select the others.

Workaround when TreeView is not databound.

Instead of adding objects directly in the TreeView's Items Collection, add RadTreeViewItems.
For Example, instead of
 treeView.Items.Add(1), 
treeView.Items.Add(2)

do

 treeView.Items.Add(new RadTreeViewItem(){Header = 1}, 
 treeView.Items.Add(new RadTreeViewItem(){Header = 2}

Workaround when TreeView is databound.

For example , if we databind the treeview to collection of DataItems and some dataitem is located in multiple places in the source collection.
Solution => Wrap the DataItem class in new class - DataItemWrapper. It can hold the underlying DataItem, add additional property  (for exampel ID) and override the Equals and GetHashCode methods.
This way different DataItemWrapper objects can hold equal DataItem objects. In such way if you bind the treeview to collection of DataItemWrappers the selection will be successful.

DECLINED:
The XAML team recently reviewed this bug  and won't be adressing it in future. It can be actually considered as feature request because selection should have notion for selected containers.
Unfortunately, the initial code design of the RadTreeView does not have such notion and the complexity of adding such feature now is very big.
(Total attached files size should be smaller than 20mb. Allowed extensions: .zip, .rar, .jpg, .png, .gif)
0 comments