You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

WPF应用ScalingWindow在客户电脑上显示透明的问题求助

WPF窗口显示异常问题求助

我使用WPF(基于.NET 5.0与MVVM模式)开发了一款应用,通过从Stack Overflow找到的OpenCloseWindowBehavior来打开三个不同窗口。公司所有电脑上运行正常,但客户电脑中的ScalingWindow出现以下问题:

  • 打开后整个窗口透明,仅鼠标悬停到按钮、文本框时,这些控件才会显示
  • 将窗口拖出屏幕边缘再拖回,显示可恢复正常

显示效果说明

  • 正常显示:窗口所有控件完整呈现,布局正常
  • 打开后异常:窗口整体透明,无可见控件
  • 鼠标悬停后:仅被鼠标覆盖的按钮、文本框显示,其余区域仍透明

MainView代码

<i:Interaction.Behaviors>
    <local:OpenCloseWindowBehavior WindowType="local:CommunicationWindow" Open="{Binding IsCommunicationOpen, Mode=TwoWay}" Context="{Binding Communication}"/>
    <local:OpenCloseWindowBehavior WindowType="local:ScalingWindow" Open="{Binding IsScalingOpen, Mode=TwoWay}" Context="{Binding Scaling}"/>
    <local:OpenCloseWindowBehavior WindowType="local:AboutWindow" Open="{Binding IsAboutOpen, Mode=TwoWay}"/>
</i:Interaction.Behaviors>

ViewModel代码

private CommunicationViewModel _communication;
public CommunicationViewModel Communication
{
    get => _communication;
    set => SetProperty(ref _communication, value);
}
private ScalingViewModel _scaling;
public ScalingViewModel Scaling
{
    get => _scaling;
    set => SetProperty(ref _scaling, value);
}

private bool _isCommunicationOpen;
public bool IsCommunicationOpen
{
    get => _isCommunicationOpen;
    set
    {
        if (value)
        {
            Communication = new(_measurementFlat.Connection);
        }
        else
        {
            Communication.Dispose();
            Communication = null;
        }
        SetProperty(ref _isCommunicationOpen, value);
    }
}

private bool _isScalingOpen;
public bool IsScalingOpen
{
    get => _isScalingOpen;
    set
    {
        if (value)
        {
            Scaling = new(_measurementFlat.Scaling);
        }
        else
        {
            Scaling.Dispose();
            Scaling = null;
        }
        SetProperty(ref _isScalingOpen, value);
    }
}

private bool _isAboutOpen;
public bool IsAboutOpen
{
    get => _isAboutOpen;
    set => SetProperty(ref _isAboutOpen, value);
}

发布设置

采用独立部署模式,目标运行时为win-x64,勾选"生成单个文件",框架依赖版本选择.NET 5.0。

已尝试的解决方法

在窗口打开后调用window.InvalidateVisual()尝试刷新,但客户反馈无效果。目前无法复现该问题,不清楚故障原因,恳请提供解决方案,若有信息缺失请指出。

内容的提问来源于stack exchange,提问作者LuP1999

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.20 21:12:29