使用 ElementHost 时加载 wpf 控件之前的黑色背景
我在 WinForms 中使用 WPF 和 ElementHost。当表单加载时,ElementHost 即将加载时会出现黑色背景闪烁。这看起来有点糟糕。关于如何摆脱这个问题有什么建议吗?
I'm using WPF in WinForms with ElementHost. When the form loads, there is a flash of black background where the ElementHost is about to load. This looks kind of bad. Any suggestions on how to get rid of this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
隐藏元素(Visibility = Hidden)直到 WinForms 控件完全加载...
Hide the element (Visibility = Hidden) until the WinForms control is fully loaded...
我知道这个问题已经得到了回答,而且这个问题已经很老了,但是所提供的答案都不适合我自己,而且经过很长时间的问题排查后。我终于找到了一个更简单的答案。
如果您在初始构造函数中构建一个从 Element Host 扩展的类。您可以为主机容器设置加载事件。宿主容器是元素宿主子级显示在其顶部的面板。从那里,只需将主机容器背景颜色设置为元素主机父对象背景颜色。
像这样
I know this has already been answered and the question is old but none of the presented answers worked for myself and after a long time of troubleshooting the issue. I finally found an easier answer.
If you build a class extending from Element Host and in the initial constructor. You can set a Load Event for the Host Container. The Host Container is the panel that the Element Hosts Child is being displayed on top of. From there, just set the Host Containers background color to being of the Element Hosts Parents background color.
Like this
您需要首先显示带有空边界的控件,以避免黑色闪烁
you need first show control with empty bounds first time to avoid black flickering