WPF drag and drop files added in the 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;
    }
    }
  }
}

Reproduced in: https: //www.cnblogs.com/aswordok/p/3813419.html

Guess you like

Origin blog.csdn.net/weixin_33894992/article/details/93726758