使用自定义启动屏幕时的 ContentControl 渲染错误 .Close() - 发生了什么?

发布于 2024-08-17 09:44:58 字数 944 浏览 6 评论 0原文

我使用非常基本的 ContentControl 在不同类型的内容之间切换:

<ContentControl Content="{Binding MyContent}">
    <ContentControl.Resources>
        <DataTemplate DataType="{x:Type local:Type1}">
            <local:View1/>
        </DataTemplate>
        <DataTemplate DataType="{x:Type local:Type2}">
            <local:View2/>
        </DataTemplate>
...
    </ContentControl.Resources>
</ContentControl>

随机(例如所有运行的 20%),当显示视图时,它显示完全透明,但不允许其后面的控件接收输入。

如果我尝试在窗口上使用 Snoop,视图会立即呈现。当我将鼠标悬停在预期的文本框上时,该视图甚至会接受输入并更改鼠标光标。如果我按“不可见”视图上的任何按钮,它就会立即弹出。

ContentControl 切换到 ContentPresenter 并没有改变上述行为。

有人知道发生了什么事以及如何解决它吗?

编辑:它看起来像是 WPF 中的一个错误,所以我最大的希望是遇到过这个问题的人。

编辑:我跟踪它到自定义启动屏幕窗口,准确地说 - 使用.Close()来摆脱窗口。如果我使用 .Hide() 代替,则不会发生故障。还是不明白为什么。

I use a pretty basic ContentControl switching between different types of content:

<ContentControl Content="{Binding MyContent}">
    <ContentControl.Resources>
        <DataTemplate DataType="{x:Type local:Type1}">
            <local:View1/>
        </DataTemplate>
        <DataTemplate DataType="{x:Type local:Type2}">
            <local:View2/>
        </DataTemplate>
...
    </ContentControl.Resources>
</ContentControl>

Randomly (like 20% of all runs), when a view is displayed, it displays completely transparent, but does not allow controls behind it to receive input.

If I try to use Snoop on the window, the view instantly renders. The view is even takes input and changes the mouse cursor when I hover over expected-to-be text boxes. If I press any button on the "invisible" view, it instantly pops up.

Switching from ContentControl to ContentPresenter did not change the above behavior.

Does anybody have a clue what is going on and how to fix it?

EDIT: It looks like a bug in WPF, so my best hope is somebody who have experienced this problem.

EDIT: I tracked it down to the custom splash screen window, being exact - to using .Close() to get rid of the window. If I use .Hide() instead, the glitch does not happen. Still not getting why.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文