wpf – .NET 4.0和WindowsFormstHost的Window Focus问题

栏目: ASP.NET · 发布时间: 7年前

内容简介:翻译自:https://stackoverflow.com/questions/4609836/window-focus-problem-with-net-4-0-and-windowsformsthost

我遇到了一些我遇到麻烦的奇怪行为:

>添加一个简单的Forms控件

文本框到WindowsFormsHost;

>添加一个打开另一个按钮

WPF窗口(不设置所有者);

>最大化原始WPF窗口

然后单击文本框以使其具有

焦点;

>当你这样做然后尝试

激活其他WPF窗口

它被激活的任务栏

然后停用.

令人不安的是,如果我在.NET 3.5下编译它,它没有问题.

有任何想法吗?

在派生窗口上实现它有点帮助 – 但不能完全解决问题:

protected override void OnDeactivated(EventArgs e)
{
  var host = System.Windows.Input.FocusManager.GetFocusedElement(this) as System.Windows.Forms.Integration.WindowsFormsHost;
  if (host !=null )
  {
    Focus();
  }

  base.OnDeactivated(e);
}

它在停用时将焦点设置到窗口 – 这还不够早,因此激活会翻转,但是当你第二次使用alt-tab切换时.但是没有保留聚焦控制.我尝试调度焦点集 – 但没有好处.

翻译自:https://stackoverflow.com/questions/4609836/window-focus-problem-with-net-4-0-and-windowsformsthost


以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Hit Refresh

Hit Refresh

Satya Nadella、Greg Shaw / HarperBusiness / 2017-9-26 / USD 20.37

Hit Refresh is about individual change, about the transformation happening inside of Microsoft and the technology that will soon impact all of our lives—the arrival of the most exciting and disruptive......一起来看看 《Hit Refresh》 这本书的介绍吧!

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

SHA 加密
SHA 加密

SHA 加密工具

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具