diff options
author | Alexander Sorokin <v-alsoro@microsoft.com> | 2017-10-19 11:07:58 +0300 |
---|---|---|
committer | Alexander Sorokin <v-alsoro@microsoft.com> | 2017-11-17 09:15:55 +0300 |
commit | 2107af1ab793598774cbae77afd44d76e2943a18 (patch) | |
tree | 45b736de44cdfddb97dd3c3efc3e35bdaeb24249 /Xwt.WPF | |
parent | 62a1472e12bf663169fada110466d38692fc7c08 (diff) |
TreeView: Let user drag multiple selected items
https://bugzilla.xamarin.com/show_bug.cgi?id=60266
Diffstat (limited to 'Xwt.WPF')
-rw-r--r-- | Xwt.WPF/Xwt.WPFBackend/ExTreeViewItem.cs | 40 |
1 files changed, 30 insertions, 10 deletions
diff --git a/Xwt.WPF/Xwt.WPFBackend/ExTreeViewItem.cs b/Xwt.WPF/Xwt.WPFBackend/ExTreeViewItem.cs index 3939dedb..9fbaf970 100644 --- a/Xwt.WPF/Xwt.WPFBackend/ExTreeViewItem.cs +++ b/Xwt.WPF/Xwt.WPFBackend/ExTreeViewItem.cs @@ -35,6 +35,8 @@ using Xwt.Backends; namespace Xwt.WPFBackend { + using Keyboard = System.Windows.Input.Keyboard;
+
public class ExTreeViewItem : TreeViewItem { @@ -125,15 +127,25 @@ namespace Xwt.WPFBackend protected override DependencyObject GetContainerForItemOverride() { return new ExTreeViewItem (this.view); - } - - protected override void OnMouseLeftButtonDown (MouseButtonEventArgs e) { - view.SelectItem(this); - e.Handled = true; - base.OnMouseLeftButtonDown(e); - } - - protected override void OnMouseDoubleClick(MouseButtonEventArgs e)
+ }
+
+ protected override void OnMouseLeftButtonDown (MouseButtonEventArgs e)
+ {
+ if (!view.SelectedItems.Contains (this.DataContext) || CtrlPressed)
+ view.SelectItem (this);
+ e.Handled = true;
+ base.OnMouseLeftButtonDown (e);
+ }
+
+ protected override void OnMouseLeftButtonUp (MouseButtonEventArgs e)
+ {
+ if (view.SelectedItems.Contains (this.DataContext) && !CtrlPressed)
+ view.SelectItem (this);
+ e.Handled = true;
+ base.OnMouseLeftButtonUp (e);
+ }
+
+ protected override void OnMouseDoubleClick (MouseButtonEventArgs e)
{ if ((view.Backend as TreeViewBackend)?.RowActivatedEventEnabled == true && IsSelected)
{
@@ -194,6 +206,14 @@ namespace Xwt.WPFBackend { BringIntoView(); //We can't allow TreeViewItem(our base class) to get this message(OnGotFocus) because it will also select this item which we don't want - } + }
+
+ private bool CtrlPressed
+ {
+ get
+ {
+ return Keyboard.IsKeyDown (WKey.RightCtrl) || Keyboard.IsKeyDown (WKey.LeftCtrl);
+ }
+ }
} } |