WPF界面不响应任何交互

Software Rendering Usage in WPF


  • wpf界面在一定情况下,会不响应任何交互,整个窗口图片一样,其实,wpf有两种方式渲染界面,硬件渲染、软件渲染。以下为找到的相关资料,下方链接为文章原地址。

https://blogs.msdn.microsoft.com/jgoldb/2010/06/22/software-rendering-usage-in-wpf/

  • WPF默认使用GPU渲染界面,即硬件渲染。

  • 大多数情况下,使用硬件渲染都能获得更好的性能。其他一些情况下,软件方式渲染可能更快。

  • WPF优先使用硬件渲染,但是在特定条件下,会使用软件渲染方式,此时界面会表现为未响应状态

  • 以下几种情况下,wpf会使用软件渲染的方式

    • 很老的显卡,2004年11月之前的硬件

    • WPF检测到名为“Tier 0”的显卡,“Tier 0”表示不支持硬件渲染,或者DirectX版本在7.0以前

    • 窗口的渲染尺寸大于显卡的渲染的最大尺寸,常发生在,窗口跨多个屏幕显示的情况

    • 在远程桌面的方式下运行程序。

      Until NET 3.5 SP1 and earlier, remoting between Vista to Vista with DWM on, leveraged a custom WPF primitive remoting protocol. In all other scenarios content was remoted as bitmaps. Starting with the release of NET 3.5 SP1 (including NET 4), WPF renders the application content using a software rasterizer on the server and then remotes the content as bitmaps in all cases.

    • 虚拟机中运行程序。WPF会先尝试用硬件渲染界面,但是在有些虚拟机中,运行异常。用户需要强制指定软件方式渲染,来避免运行异常,使用如下代码来指定软件方式渲染:

          RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly;       // Force Software rendering per Process – New in NET4
          hwndTarget.RenderMode = RenderMode.SoftwareOnly;        // Force Software rendering per Window– Introduced in Net 3.5 SP1
      
      
    • 在注册表中指定了,不使用硬件方式渲染。

      (HKEY_CURRENT_USER\Software\Microsoft\Avalon.Graphics]
      “DisableHWAcceleration”=dword:00000000 )

      注意: 该键会影响所有wfp界面,仅在测试的时候使用

    • Application uses legacy style bitmap effects.Note: these are obsolete in NET4.

    • Application printed content.

    • Rasterized content that uses RenderTargetBitmap

    • Tiled content that uses TileBrush

    • Use of too many light objects in your 3D scene. Read more here.

    • Layered windows (only on XP SP2/W2k3 or before that do not have Hotfix installed.

    • Graphics hardware failures, such as “Out Of Video Memory” (OOVM).

    • WPF try to free up video memory and stay in HW rendering but it may not always work and WPF will fall to Software

  • 可以使用WPF Performance Profiling Tools中的Perforator来检测程序使用那种方式渲染。具体看这里

OptionDescription
Draw software rendering with purple tintDraws all areas rendered by using the software rendering pipeline with a purple tint. This includes software render targets, software 3D content, and per-primitive software fallback.
Draw software rendered bitmap effects with red tintDraws legacy software rendered bitmap effects with red tint.
  • 如何在代码中检测渲染方式?
    • 检查 RenderingCapability.Tier,同时也可以监听Tier变化事件。
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值