I have used a DatagridDragDropTarget from Silverlight-Toolkit I found at Codeplex. When I drag a row in the datagrid I want to get the variable ID from the row. When I drop the row over the target (another datagrid) the function DataGridDragDropTarget_ItemDragCompleted is called. This function is not working 100 % because I cant figure out the way to print the column ID in the row I dragged. As you can see at the video I posted at youtube!
the label prints out
System.Collection.Objectmode.selection
When I debug. Here is the function:
private void DataGridDragDropTarget_ItemDragCompleted(object sender, ItemDragEventArgs e)
{
Label1.Content = "Function is called";
SelectionCollection secCol = e.Data as SelectionCollection;
for (int i = 0; i < secCol.Count; i++)
{
Label1.Content += " " + secCol[i].ToString();
}
}
And here is most important part of the xaml. The full source code can be found at my dropbox:
<toolkit:DataGridDragDropTarget AllowDrop="True"
AllowedSourceEffects="Copy"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Margin="10, 10, 0, 0"
ItemDragCompleted="DataGridDragDropTarget_ItemDragCompleted" >
<sdk:DataGrid AutoGenerateColumns="False"
Height="150"
HorizontalAlignment="Left"
Name="FirstGrid"
VerticalAlignment="Top"
Width="476"
ColumnWidth="*"
SelectionMode="Extended"
ItemsSource="{Binding}">
<sdk:DataGrid.Columns>
<sdk:DataGridTextColumn Binding="{Binding ID}"
Header="Id" />
<sdk:DataGridTextColumn Binding="{Binding Name}"
Header="Name" />
<sdk:DataGridTextColumn Binding="{Binding BookTitle}"
Header="BookTitle" />
<sdk:DataGridTextColumn Binding="{Binding DOB}"
Header="DOB" />
<sdk:DataGridTextColumn Binding="{Binding IsMVP}"
Header="IsMVP" />
</sdk:DataGrid.Columns>
</sdk:DataGrid>
</toolkit:DataGridDragDropTarget>
<sdk:Label Name="Label1" Height="28" Width="420" Margin="140,0"/>
<sdk:DataGrid AllowDrop="True" Height="125" Margin="92,0,81,0"/>
YourBindedClass secCol = e.Data as YourBindedClass;
//This is the datarow. You can access the properties then,
Label1.Content = secCol.Property1.ToString();