适用环境:Windows 10 X64

 

修改注册表:

计算机\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System\EnableLUA

的值为0

 

<TextBox Grid.Row="0" Grid.Column="0" AllowDrop="True" PreviewDragEnter="WhenPreviewDragOver" PreviewDragOver="WhenPreviewDragOver" Drop="WhenFileDrop" Background="Pink" Text="TextBox"></TextBox>

 

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

        private void WhenFileDrop(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(DataFormats.FileDrop, false))
            {
                string[] filePaths = e.Data.GetData(DataFormats.FileDrop) as string[];

                if (filePaths != null)
                {
                    MessageBox.Show(string.Join(Environment.NewLine, filePaths));
                }
            }
        }

  

 

相关文章:

  • 2022-12-23
  • 2021-07-24
  • 2022-12-23
  • 2021-10-04
  • 2022-02-21
  • 2021-07-27
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-10-16
  • 2021-05-24
  • 2022-01-22
  • 2021-08-30
相关资源
相似解决方案