Skip to content

Commit 3dc6e0d

Browse files
authored
Merge pull request #405 from vadzimshch/fix404
Fix for #404
2 parents 3e72b23 + a7f507f commit 3dc6e0d

File tree

4 files changed

+33
-17
lines changed

4 files changed

+33
-17
lines changed

src/GongSolutions.WPF.DragDrop/DropInfo.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,8 @@ public DropInfo(object sender, DragEventArgs e, [CanBeNull] DragInfo dragInfo, E
179179

180180
this.InsertPosition |= RelativeInsertPosition.TargetItemCenter;
181181
}
182-
//System.Diagnostics.Debug.WriteLine("==> DropInfo: pos={0}, idx={1}, Y={2}, Item={3}", this.InsertPosition, this.InsertIndex, currentYPos, item);
182+
183+
// System.Diagnostics.Debug.WriteLine($"==> DropInfo: pos={this.InsertPosition}, index={this.InsertIndex}, currentXPos={currentXPos}, Item={this.item}");
183184
}
184185
else
185186
{
@@ -188,7 +189,7 @@ public DropInfo(object sender, DragEventArgs e, [CanBeNull] DragInfo dragInfo, E
188189

189190
if (this.VisualTargetFlowDirection == FlowDirection.RightToLeft)
190191
{
191-
if (currentXPos > targetWidth / 2)
192+
if (currentXPos < targetWidth / 2)
192193
{
193194
this.InsertPosition = RelativeInsertPosition.BeforeTargetItem;
194195
}
@@ -221,7 +222,8 @@ public DropInfo(object sender, DragEventArgs e, [CanBeNull] DragInfo dragInfo, E
221222

222223
this.InsertPosition |= RelativeInsertPosition.TargetItemCenter;
223224
}
224-
//System.Diagnostics.Debug.WriteLine("==> DropInfo: pos={0}, idx={1}, X={2}, Item={3}", this.InsertPosition, this.InsertIndex, currentXPos, item);
225+
226+
// System.Diagnostics.Debug.WriteLine($"==> DropInfo: pos={this.InsertPosition}, index={this.InsertIndex}, currentXPos={currentXPos}, Item={this.item}");
225227
}
226228
}
227229
else

src/GongSolutions.WPF.DragDrop/DropTargetInsertionAdorner.cs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -133,18 +133,7 @@ protected override void OnRender(DrawingContext drawingContext)
133133
}
134134
else
135135
{
136-
if (dropInfo.VisualTargetFlowDirection == FlowDirection.LeftToRight && dropInfo.InsertIndex == itemsCount)
137-
{
138-
if (itemsCount > 0)
139-
{
140-
itemRect.X += itemContainer.RenderSize.Width;
141-
}
142-
else
143-
{
144-
itemRect.X += this.Pen.Thickness;
145-
}
146-
}
147-
else if (dropInfo.VisualTargetFlowDirection == FlowDirection.RightToLeft && dropInfo.InsertIndex != itemsCount)
136+
if (dropInfo.InsertIndex == itemsCount)
148137
{
149138
if (itemsCount > 0)
150139
{

src/GongSolutions.WPF.DragDrop/Utilities/DragDropExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ private static BitmapSource CaptureScreen(Visual target, FlowDirection flowDirec
127127
{
128128
var transformGroup = new TransformGroup();
129129
transformGroup.Children.Add(new ScaleTransform(-1, 1));
130-
transformGroup.Children.Add(new TranslateTransform(bounds.Size.Width - 1, 0));
130+
transformGroup.Children.Add(new TranslateTransform(bounds.Size.Width, 0));
131131
ctx.PushTransform(transformGroup);
132132
}
133133

src/Showcase/Views/ListBoxSamples.xaml

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,36 @@
123123
<StackPanel>
124124
<TextBlock Style="{StaticResource DefaultTextBlockStyle}" Text="Demonstrates the default behaviour with horizontal ListBoxes and right to left flow direction." />
125125
<TextBlock Style="{StaticResource DefaultTextBlockStyle}" Text="Unbound ListBox" />
126-
<ListBox Height="Auto"
126+
<ListBox MinHeight="30"
127+
Height="Auto"
128+
dd:DragDrop.DefaultDragAdornerOpacity="0.5"
129+
dd:DragDrop.IsDragSource="True"
130+
dd:DragDrop.IsDropTarget="True"
131+
dd:DragDrop.UseDefaultDragAdorner="True"
132+
dd:DragDrop.UseDefaultEffectDataTemplate="True"
133+
dd:DragDrop.ShowAlwaysDropTargetAdorner="True"
134+
SelectionMode="Extended">
135+
<ListBox.ItemsPanel>
136+
<ItemsPanelTemplate>
137+
<StackPanel Margin="1" Orientation="Horizontal" />
138+
</ItemsPanelTemplate>
139+
</ListBox.ItemsPanel>
140+
<ListBoxItem>ListBoxItem1</ListBoxItem>
141+
<ListBoxItem>ListBoxItem2</ListBoxItem>
142+
<ListBoxItem>ListBoxItem3</ListBoxItem>
143+
<ListBoxItem>ListBoxItem4</ListBoxItem>
144+
<ListBoxItem>ListBoxItem5</ListBoxItem>
145+
</ListBox>
146+
<TextBlock Style="{StaticResource DefaultTextBlockStyle}" Text="ListBox with right to left flow direction" />
147+
<ListBox MinHeight="30"
148+
Height="Auto"
149+
FlowDirection="RightToLeft"
127150
dd:DragDrop.DefaultDragAdornerOpacity="0.5"
128151
dd:DragDrop.IsDragSource="True"
129152
dd:DragDrop.IsDropTarget="True"
130153
dd:DragDrop.UseDefaultDragAdorner="True"
154+
dd:DragDrop.UseDefaultEffectDataTemplate="True"
155+
dd:DragDrop.ShowAlwaysDropTargetAdorner="True"
131156
SelectionMode="Extended">
132157
<ListBox.ItemsPanel>
133158
<ItemsPanelTemplate>

0 commit comments

Comments
 (0)