代码之家  ›  专栏  ›  技术社区  ›  palehorse

WPF透明边框导致UI停止重新绘制

  •  2
  • palehorse  · 技术社区  · 17 年前

    作为后续行动 my previous question ,我想知道如何正确使用透明窗口。如果我将窗口设置为使用透明度,UI偶尔会停止响应。实际发生的情况是,用户界面根本没有按应有的方式更新。动画不会出现,页面似乎无法导航;但是,如果您看到调试器单击按钮、链接等。。确实有效。最小化和恢复窗口会再次“捕获”UI,用户可以继续工作,直到行为恢复。

    下面是我对失败代码的窗口声明。

    <Window x:Class="MyProject.MainContainer"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="WPF APplication" Height="600" Width="800"    
        xmlns:egc="ControlLibrary" Background="{x:Null}"
        BorderThickness="0"
        AllowsTransparency="True"
        MinHeight="300" MinWidth="400" WindowStyle="None" >
    

    <Window x:Class="MyProject.MainContainer"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="WPF Application" Height="600" Width="800"    
        xmlns:egc="ControlLibrary" Background="{x:Null}"
        BorderThickness="0"
        AllowsTransparency="False"
        MinHeight="300" MinWidth="400" WindowStyle="None" >
    
    3 回复  |  直到 9 年前
        1
  •  2
  •   Abe Heidebrecht    17 年前

    不幸的是,要解决此问题,您只能升级到.NET 3.0 SP1(包含在.NET 3.5中),并安装适用于Windows的service pack。请注意,透明窗口的速度仍然较慢,但没有那么差。您可以找到更深入的讨论 here .

        2
  •  1
  •   palehorse    17 年前

    我想我终于找到了解决办法。从我所读到的一切来看,这个问题不应该发生在XP SP3&上。NET3.5SP1,但它是。

    this blog post 演示如何使用Win32 API函数创建不规则形状的窗口,这正是我正在做的。在使用这些技术对我的主窗口进行返工后,事情似乎按预期进行,并且行为没有返回。

    值得注意的是,作者推荐这种方法的原因是WPF和透明窗口的性能问题。虽然我相信它在.NET3.5SP1中可能会更好,但实现起来并不是那么难,应该会表现得更好。

        3
  •  0
  •   palehorse    17 年前

    我在Windows XP Pro SP3上运行,并使用.NET 3.5 SP1。我还验证了该项目的目标是框架的3.5版本。

    推荐文章