From 04b9138dc6798cb96385c9771fc76b81799d3ba1 Mon Sep 17 00:00:00 2001
From: George <fitdev@users.noreply.github.com>
Date: Thu, 17 Aug 2023 20:15:15 +0300
Subject: [PATCH 1/3] Update ContextDragBehavior.cs (#1)

Fixes an issue where there is a multi-item selection in `ListBox` control which gets cleared when this behavior is attached to a `ListItem`
---
 .../ContextDragBehavior.cs                                       | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/Avalonia.Xaml.Interactions.DragAndDrop/ContextDragBehavior.cs b/src/Avalonia.Xaml.Interactions.DragAndDrop/ContextDragBehavior.cs
index f2e89fbe..839cc145 100644
--- a/src/Avalonia.Xaml.Interactions.DragAndDrop/ContextDragBehavior.cs
+++ b/src/Avalonia.Xaml.Interactions.DragAndDrop/ContextDragBehavior.cs
@@ -136,6 +136,7 @@ private void AssociatedObject_PointerPressed(object? sender, PointerPressedEvent
             if (e.Source is Control control
                 && AssociatedObject?.DataContext == control.DataContext)
             {
+                if ((control as ISelectable ?? control.Parent as ISelectable)?.IsSelected ?? false) e.Handled = true; //avoid deselection on drag
                 _dragStartPoint = e.GetPosition(null);
                 _triggerEvent = e;
                 _lock = true;

From 099c1d11921534b8dbeafea2572485a196d377c2 Mon Sep 17 00:00:00 2001
From: George <fitdev@users.noreply.github.com>
Date: Thu, 17 Aug 2023 21:08:35 +0300
Subject: [PATCH 2/3] Update ContextDragBehavior.cs

---
 .../ContextDragBehavior.cs                                      | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/Avalonia.Xaml.Interactions.DragAndDrop/ContextDragBehavior.cs b/src/Avalonia.Xaml.Interactions.DragAndDrop/ContextDragBehavior.cs
index 839cc145..3e7d73f0 100644
--- a/src/Avalonia.Xaml.Interactions.DragAndDrop/ContextDragBehavior.cs
+++ b/src/Avalonia.Xaml.Interactions.DragAndDrop/ContextDragBehavior.cs
@@ -136,7 +136,7 @@ private void AssociatedObject_PointerPressed(object? sender, PointerPressedEvent
             if (e.Source is Control control
                 && AssociatedObject?.DataContext == control.DataContext)
             {
-                if ((control as ISelectable ?? control.Parent as ISelectable)?.IsSelected ?? false) e.Handled = true; //avoid deselection on drag
+                if ((control as ISelectable ?? control.Parent as ISelectable ?? control.FindLogicalAncestorOfType<ISelectable>())?.IsSelected ?? false) e.Handled = true; //avoid deselection on drag
                 _dragStartPoint = e.GetPosition(null);
                 _triggerEvent = e;
                 _lock = true;

From f1bc929c6bbf7b319c295054fc3669d459766b66 Mon Sep 17 00:00:00 2001
From: George <fitdev@users.noreply.github.com>
Date: Thu, 17 Aug 2023 21:12:29 +0300
Subject: [PATCH 3/3] Update ContextDragBehavior.cs

---
 .../ContextDragBehavior.cs                                       | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/Avalonia.Xaml.Interactions.DragAndDrop/ContextDragBehavior.cs b/src/Avalonia.Xaml.Interactions.DragAndDrop/ContextDragBehavior.cs
index 3e7d73f0..3ca06120 100644
--- a/src/Avalonia.Xaml.Interactions.DragAndDrop/ContextDragBehavior.cs
+++ b/src/Avalonia.Xaml.Interactions.DragAndDrop/ContextDragBehavior.cs
@@ -3,6 +3,7 @@
 using Avalonia.Controls;
 using Avalonia.Input;
 using Avalonia.Interactivity;
+using Avalonia.LogicalTree;
 using Avalonia.Xaml.Interactivity;
 
 namespace Avalonia.Xaml.Interactions.DragAndDrop;