首页 > 解决方案 > 在外部浏览器进程中拖放到 WEB 页面后,我的窗口 (WPF) 没有响应

问题描述

在我的 WPF 应用程序中,调用并以模态方式显示一个小窗口,用户(使用拖放)必须将两个字符串从该窗口拖到 WEP 页面上,该页面显示在单独的浏览器进程中。只要在显示 WPF 窗口时用户不在 WEP 页面上执行进一步的活动,这也很有效。

public partial class WidgetWnd : Window
{
  public WidgetWnd(string WindowTitle, string UserIdent, string Password)
  {
    InitializeComponent();
  }

  private void LeftBtn_PreviewMouseMove(object sender, MouseEventArgs e)
  {
    leftBtn = sender as Button;
    if ((leftBtn != null) && (e.LeftButton == MouseButtonState.Pressed))
    {
      DragDrop.DoDragDrop(leftBtn, UserIdent, DragDropEffects.Copy);
    }
  }

  private void RightBtn_PreviewMouseMove(object sender, MouseEventArgs e)
  {
    rightBtn = sender as Button;
    if ((rightBtn != null) && (e.LeftButton == MouseButtonState.Pressed))
    {
      DragDrop.DoDragDrop(rightBtn, Password, DragDropEffects.Copy);
    }
  }

  private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
  {
    e.Cancel = false;
  }
}

如果用户现在关闭窗口,或者在他已经关闭 WEB 页面后关闭,则 WPF 窗口和整个程序都会被阻止(无响应)。那有什么问题?这不会发生在小型测试程序(System.Windows.Forms)中!

标签: wpfbrowserprocessdragdrop

解决方案


推荐阅读