This is a migrated thread and some comments may be shown as answers.

Editable sortable treeview

2 Answers 95 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
luc
Top achievements
Rank 1
luc asked on 18 Jan 2014, 09:43 PM

Hi,


I implemented a sortable collection to use like itemssource for my RadTreeview. Each item is editable and when item is validated the sortable collection sort well the item. Normal behavior would be

1 User start edit the item

2 User enter Enter key

3 Item is validated

4 Item is sorted in sortablecollection and RadTreeView is updated. IsInEditMode is false.



All works fine except if i decide to bind the IsInEditMode with a property of my model. When the IsInEditMode is binding (Mode TwoWay) the user must press twice Enter to complete the edit.



I join a sample here.



If you launch the sample and try to rename the 7ABC item in 0AAA, the item is well move to first position but stay in editmode. If you comment the following  line in MainWindow.xaml

<Setter Property="IsInEditMode" Value="{Binding IsInEditMode,Mode=TwoWay}"/>
the item is well move and exit from editmode when press Enter.



I don't understand why the binding on IsInEditMode interfer with edition.



Regards

Luc

2 Answers, 1 is accepted

Sort by
0
Accepted
Boris
Telerik team
answered on 22 Jan 2014, 05:00 PM
Hello luc,

We found the cause of the issue and implemented a workaround for it. The issue was in the SortableCollection class:
if (oldIndex != i)
                        {
                            this.MoveItem(oldIndex, i);
                        }
where the MoveItem() method of the ObservableCollection raises a CollectionChanged event. This triggers refresh of the ItemsSource property of the RadTreeView and this prevents the proper ending of the edit mode. 
 
The workaround for this issue is to set the IsInEditingMode to "false"  manually: 
if (oldIndex != i)
                        {
                            this.MoveItem(oldIndex, i);
                            item.IsInEditMode = false;
                        }

We have also attached the sample project with the suggested approach.

I hope this information is helpful to you.

Regards,
Boris Penev
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
luc
Top achievements
Rank 1
answered on 22 Jan 2014, 05:14 PM
Hi,

Thanks it's work for this little project. More complicated with a generic SortableCollection<T> because IsInEditMode is not accessible.

But i don't understand why when I comment the IsInEditMode bindings the behavior is different. In this case the CollectionChanged is raised too and the item exit from edition.

Regards
Tags
TreeView
Asked by
luc
Top achievements
Rank 1
Answers by
Boris
Telerik team
luc
Top achievements
Rank 1
Share this question
or