WPF拖放操作中DragDropEffects.Move不起作用
拖放操作中DragDropEffects.Move不起作用。下面的代码将文本从一个文本框拖放到一个标签中,用了DragDropEffects.Move,标签中有文字了,但文本框里面的文字没有移动掉,什么原因?
private void textBox1_MouseDown(object sender, MouseButtonEventArgs e)
{
TextBox txt = sender as TextBox;
DragDrop.DoDragDrop(txt, txt.Text, DragDropEffects.Move);
}
private void lblDrop_Drop(object sender, DragEventArgs e)
{
((Label)sender).Content= e.Data.GetData(DataFormats.Text);
}
private void lblDrop_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.Text))
{
e.Effects = DragDropEffects.Move;
}
else
e.Effects = DragDropEffects.None;
}
wpf 拖放
[解决办法]
e.Effects = DragDropEffects.Move;
Debug看看e.Effects得到什么赋值?