I want to do something like I have two shortcuts
A ......................... B
______........... _______
| RED | .......... | GREEN | ----------.......... -----------
When I drag A to B OR B to A, the exchange text
A ......................... B
______.............. _____
| GREEN | .......... | RED | ----------............... ---------
I did it a bit
main window

When I drag text from code , drop label appears
When I drag red to green:

My code is:
private void Label_MouseDown(object sender, MouseButtonEventArgs e)
{
Label lblFrom = e.Source as Label;
if (e.LeftButton == MouseButtonState.Pressed)
DragDrop.DoDragDrop(lblFrom, lblFrom.Content, DragDropEffects.Copy);
}
private void Label_QueryContinueDrag(object sender, QueryContinueDragEventArgs e)
{
Label lblFrom = e.Source as Label;
if (!e.KeyStates.HasFlag(DragDropKeyStates.LeftMouseButton))
lblFrom.Content = "RED";
}
private void Label_Drop(object sender, DragEventArgs e)
{
string draggedText = (string)e.Data.GetData(DataFormats.StringFormat);
Label toLabel = e.Source as Label;
toLabel.Content = draggedText;
}
}
source
share