Drag and drop into grid not dropping properly
<p>I have found the code here:</p>

<blockquote>
  <p><a href="https://social.msdn.microsoft.com/Forums/en-US/b01a66ef-ae83-4891-9fe9-74ed2f4fd99c/drag-and-drop-images?forum=wpf" rel="nofollow noreferrer">https://social.msdn.microsoft.com/Forums/en-US/b01a66ef-ae83-4891-9fe9-74ed2f4fd99c/drag-and-drop-images?forum=wpf</a></p>
</blockquote>

<p>which seems really what I need that is drag and drop into a grid with column definition.</p>

<p>So I have that:</p>

<pre><code>&lt;Window x:Class="WpfApplication1.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:local="clr-namespace:WpfApplication1"
    mc:Ignorable="d"
    Title="MainWindow" Height="350" Width="525"&gt;
    &lt;Grid PreviewMouseLeftButtonDown="Grid_PreviewMouseLeftButtonDown" Background="Transparent"
      PreviewMouseMove="Grid_PreviewMouseMove"
      DragEnter="Grid_DragEnter"
      Drop="Grid_Drop"
      AllowDrop="True"&gt;
      &lt;Grid.ColumnDefinitions&gt;
        &lt;ColumnDefinition/&gt;
        &lt;ColumnDefinition/&gt;
      &lt;/Grid.ColumnDefinitions&gt;
      &lt;Grid.RowDefinitions&gt;
        &lt;RowDefinition/&gt;
        &lt;RowDefinition/&gt;
      &lt;/Grid.RowDefinitions&gt;
      &lt;Image x:Name="Ld" Margin="5" Grid.Row="0" Grid.Column="0" Source="greenBall.ico"/&gt;
      &lt;Image x:Name="iar" Margin="5" Grid.Row="1" Grid.Column="0" Source="greenBall.ico"/&gt;
      &lt;Image x:Name="ry" Margin="5" Grid.Row="0" Grid.Column="1" Source="greenBall.ico"/&gt;
      &lt;Image x:Name="dia" Margin="5" Grid.Row="1" Grid.Column="1" Source="greenBall.ico"/&gt;
   &lt;/Grid&gt;
</code></pre>

<p>
and the effect is the one in the pic</p>

<p><a href="https://i.stack.imgur.com/5osKW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5osKW.png" alt="enter image description here"></a></p>

<p>The code behind is:</p>

<pre><code>public partial class MainWindow : Window
{

  private Point startDragPoint;
  Image dragImage = new Image();

  public MainWindow()
  {
    InitializeComponent();
  }

  private void Grid_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
  {
    dragImage = e.Source as Image;
    startDragPoint = e.GetPosition(null);
  }

  private void Grid_PreviewMouseMove(object sender, MouseEventArgs e)
  {
    if (e.LeftButton == MouseButtonState.Pressed)
    {
      Point position = e.GetPosition(null);

      if (Math.Abs(position.X - startDragPoint.X) &gt;
             SystemParameters.MinimumHorizontalDragDistance ||
          Math.Abs(position.Y - startDragPoint.Y) &gt;
             SystemParameters.MinimumVerticalDragDistance)

      {
        DataObject data = new DataObject(typeof(ImageSource), dragImage.Source);
        DragDrop.DoDragDrop(dragImage, data, DragDropEffects.Move);
      }
    }
  }

  private void Grid_DragEnter(object sender, DragEventArgs e)
  {
    if (e.Data.GetDataPresent(typeof(DataObject)))
    {
      e.Effects = DragDropEffects.Copy;
    }
    else
    {
      e.Effects = DragDropEffects.None;
    }
}

  private void Grid_Drop(object sender, DragEventArgs e)
  {
    Image dropImage = e.Source as Image;
    double x = dropImage.ActualWidth;

    dragImage.Source = dropImage.Source;
    dropImage.Source = e.Data.GetData(typeof(ImageSource)) as ImageSource;

  }
 }
</code></pre>

<p>Now when I drag and drop the red ball the effect is that nothing appears</p>

<p><a href="https://i.stack.imgur.com/yB6Cg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yB6Cg.png" alt="enter image description here"></a></p>

<p>I am no WPF expert but I see that dropImage.source is null</p>

<p><a href="https://i.stack.imgur.com/VaAXj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VaAXj.png" alt="enter image description here"></a></p>

<p>It's not necessary to keep the same code all what I need is to put drag and drop images into a grid column and row definitions
Thanks in advance</p>