mono / xwt

A cross-platform UI toolkit for creating desktop applications with .NET and Mono
MIT License
1.37k stars 241 forks source link

[WPF] TreeView's SelectionChanged event gets called twice #303

Open jfreax opened 10 years ago

jfreax commented 10 years ago

The SelectionChanged event on a TreeView will always executed twice per click. This problem seems to only occur in single selection mode. The error also occurs in the TreeView Sample.

I have no idea of WPF. However, it appears that in this line is something wrong. https://github.com/mono/xwt/blob/master/Xwt.WPF/Xwt.WPFBackend/ExTreeView.cs#L264 If I delete these both lines, then it works fine for me.

I am using Windows 7 with .Net 4.5.

sevoku commented 9 years ago

I think it happens because the implementation tracks the selection as an ObservableCollection. In this case there is really more then one change that trigger the event: 1. remove old item from selection, 2. select new item. A workaround could be to check which selection mode is used and to ignore the remove action.