Windows 10 上的空白 WPF 子窗口 [英] Blank WPF child windows on Windows 10

查看:25
本文介绍了Windows 10 上的空白 WPF 子窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从 Windows 8.1(64 位)升级了 Windows 10.在 WPF 应用程序(由我或其他人开发,如屏幕截图中的 todotxt.net)中,子窗口大部分时间都是空白的.

I have Windows 10 upgraded from Windows 8.1 (64 bit). In WPF applications (developed by me or by others, like todotxt.net on the screenshots) child windows are blank most of the time.

如果我将鼠标移到控件上,它们中的一些会出现(我猜是因为它们处理 WM_MOUSEHOVER 消息以重新绘制自己).有时窗口没问题(大约 10-20% 的启动).我通过隐藏和显示控件暂时解决了这个问题(请阅读下文).

If I move a mouse over the controls, some of them appear (I guess because they handle WM_MOUSEHOVER message to repaint themselves). Sometimes windows are OK (~10-20% of launches). I have temporarily fixed the issue by hiding and showing the controls (please read below).

在 Hyper-V 上全新安装 Windows 10 不会重现该错误.

Fresh installation of Windows 10 on Hyper-V does not reproduce the error.

有没有人遇到过类似的问题?你是怎么解决的?

这是它的外观(空白子窗口):

Here how it looks (blank child window):

鼠标移动后:

我的解决方案

我无法在 Internet 上找到任何其他解决方案.如果您找到任何其他解决方案,请告诉我.

I was not able to find any other solution on the Internet. If you find any other solution, please let me know.

首先,简单的重绘(通过InvalidateVisual())并没有解决问题.

First, simple repainting (via InvalidateVisual()) did not solve the problem.

我决定处理 ContentRendered 事件并隐藏然后显示所有控件.这个技巧有效,但它闻起来".

I decided to handle the ContentRendered event and hide and then show back all the controls. The trick works, but it "smells".

在下面的代码中,mainGrid 是我的子窗口最顶层网格的名称:

In the code below mainGrid is a name of the topmost Grid of my child window:

XAML:

<Window x:Class="MyApp.About"
    .........
    ContentRendered="Window_ContentRendered" 
    ...... >
    <Grid x:Name="mainGrid" ... >

CS:

private void Window_ContentRendered(object sender, EventArgs e)
{
    InvalidateVisual(); // Just in case
    var childCount = VisualTreeHelper.GetChildrenCount(mainGrid);

    for (int i = 0; i < childCount; ++i)
    {
        var child = VisualTreeHelper.GetChild(mainGrid, i) as UIElement;

        if (child != null)
        {
            child.Visibility = Visibility.Hidden;
            child.Visibility = Visibility.Visible;
        }
    }
}

推荐答案

根据我的观察,这仅是 Windows 10 上的 Intel GPU 驱动程序问题(Windows 8 没问题).我们有一个拥有数千名用户的 WPF 桌面应用程序,该应用程序在 Windows 7、8、8.1 中运行良好,但在 Windows 10 中安装时,某些 Windows 10 运行良好,但有些将出现该线程所解释的内容.

From my observation, this is an Intel GPU driver issue on Windows 10 only (windows 8 were fine). We have a WPF desktop application with thousands of users that runs well in Windows 7, 8, 8.1 but when installed in Windows 10, some of the Windows 10 are working well but some will appear exactly what this thread explains.

要解决此问题,最简单的方法是更新有问题机器的 Intel GPU 驱动程序.如果您拼命发现即使您已运行最新的 Windows 更新也无济于事,并且问题仍然存在,请尝试通过以下方式手动更新驱动程序:

To resolve this issue, the simplest method is to update the Intel GPU driver of the problematic machine. If you are desperately finding it doesn't help even you have run the latest Windows updates and the problem still persists, try to update the driver manually by:

  1. 在设备管理器"中,右键单击图形卡并选择更新驱动程序".
  2. 通过这种方式,Windows 10 将尝试查找有时在 Windows 更新中不可用的最新驱动程序.
  3. 如果设备管理器告知您的驱动程序已经是最新版本,最后的办法是在此处查找驱动程序:https://downloadcenter.intel.com/

对于某些机器,例如Microsoft Surface 3(不是 Surface Pro)运行着一种新的 CPU/GPU(Atom X7),更新驱动程序似乎还不可能,我仍在为这种机器寻找解决方案.

For some machine, e.g. Microsoft Surface 3 (not surface pro) that running kinda new CPU/GPU (Atom X7), update driver seems not possible yet and I am still finding resolution for this kind of machines.

在其他情况下,我的大部分 Intel HD GPU 在更新到驱动程序版本 10.18.15.4278 后都解决了这个问题

In other cases, most of my Intel HD GPU solved this problem after updating to driver version 10.18.15.4278

注 1:我还没有看到这个问题出现在其他 GPU 上,比如 Nvidia 或 ATI.注 2:一般来说,除了最新的 Intel Atom X5/X7 之外,大多数其他 Intel HD Graphic 应该能够执行驱动程序更新并解决此问题.

Note 1: I have not seen this problem appear in other GPU, so far, say Nvidia or ATI. Note 2: In general, i would say, other than the latest Intel Atom X5/X7, most of the other Intel HD Graphic should be able to perform driver update and get this problem solved.

这篇关于Windows 10 上的空白 WPF 子窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆