I have a stack panel for which AllowDrop property is true and I have to drag a user control (Player.xaml) on this stack panel.
Inside the Drop event of Stack Panel, I have to check if the items being dragged are of the user control (Player.xaml) type
private void StackPanel_Drop(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent("ProjectName.FolderName.Player"))
{
spHolder.Children.Clear();
spHolder.Children.Add((UserControls.AnswerControl)e.Data.GetData("ProjectName.FolderName.Player"));
}
}
If I would have been dropping a simple text on control, I would done like this:
private void StackPanel_Drop(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.StringFormat))
{
spHolder.Children.Clear();
spHolder.Children.Add((UserControls.AnswerControl)e.Data.GetData(DataFormats.StringFormat));
}
}
But what I should I do when I am dropping the custom user control on the stack panel? what is the format to be specificed for this thing?
Use
Or