WPF中textbox加入文件拖放操作

namespace WpfApplication1
{
  public partial class MainWindow : Window
  {
    public MainWindow()
    {
      InitializeComponent();
    }

    private void textbox1_PreviewDragOver(object sender, DragEventArgs e)
    {
      e.Effects = DragDropEffects.Copy;
      e.Handled = true;
    }

    private void textbox1_PreviewDrop(object sender, DragEventArgs e)
    {
      foreach (string f in (string[])e.Data.GetData(DataFormats.FileDrop))
    {
      textbox1.Text = f;
    }
    }
  }
}

posted @ 2014-06-28 15:34  一 剑  阅读(1089)  评论(0编辑  收藏  举报