【问题标题】:Windows Form Control doesn't appear in WPF windows when set AllowTransparency=True设置 AllowTransparency=True 时,Windows 窗体控件不会出现在 WPF 窗口中
【发布时间】:2014-11-07 10:13:16
【问题描述】:

现在我的任务是将 Windows 窗体面板添加到 WPF 窗口。 我使用默认模式运行,它运行正常,但是当我更改为 AllowTransparency=True 时,所有 Windows 窗体控件都消失了。

这是我在here之后向控件添加面板的代码

这里是源代码:

 System.Windows.Forms.Panel myPanel = new System.Windows.Forms.Panel();
 myPanel.BackColor = System.Drawing.Color.AliceBlue;
 myPanel.Visible = true;
 myPanel.Width = 500;
 myPanel.Height = 500;

WindowsFormsHost myHost = new WindowsFormsHost();
myHost.Child = myPanel;
ui_aaa.Children.Clear();
ui_aaa.Children.Add(myHost);
ui_aaa.UpdateDefaultStyle();

我需要找到在 AllowTransparency 模式下显示面板的方法。谢谢

【问题讨论】:

  • WPF 使用每像素 Alpha 透明度。这与使用 24bpp GDI 渲染的旧版 Windows 控件非常不兼容,这些控件变得完全不可见。 WPF 中的标准“空域”问题之一。
  • 感谢您的帮助。意思是当WPF中的Window设置AllowTransparency=true时,无法在WPF中加载Winforms控件,是不是

标签: c# wpf windows winforms


【解决方案1】:

由于 WPF 和 windows 窗体在 AllowTransparency 模式下显示时的不同,WPF 中的 per-pixel vs WinForm 中的 24 bpp GDI,我们无法在 WPF 中以 AllowTransperency 模式显示 Windows 窗体控件

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2010-09-25
    • 2017-10-18
    • 2012-05-31
    • 2011-06-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多