简体   繁体   English

如何在Winforms / WPF中创建透明ElementHost

[英]How to create Transparent ElementHost's in Winforms/WPF

long time lurker and self taught OOP and c# thanks in good majority to the great people here. 长期潜伏和自学的OOP和C#非常感谢这里的优秀人才。 99% of my problems I seem to find out by searching all over the net but I'm stuck with this one. 我似乎有99%的问题是通过网上搜索找到的,但我对此一无所知。

My problem is that I have a custom GUI where I'm stacking elementhost control elements that host WPF user controls. 我的问题是我有一个自定义GUI,在其中堆叠了承载WPF用户控件的elementhost控件元素。 I have successfully made these graphics appear and perform their behavior but they are not transparent with respect to each other. 我已经成功地使这些图形出现并执行了它们的行为,但是它们彼此之间并不透明。 I have stacked icons that overlap each other with a semi transparent edges where they should blend together. 我堆叠的图标相互重叠,并带有半透明的边缘,它们应融合在一起。 The icons were made in paint.net and indeed have correct graphics for transparency. 这些图标是在paint.net中制作的,确实具有正确的图形以提高透明度。 Using host.BackColorTransparency = true, I was able to make these element hosts transparent to background of my winforms GUI, but they are still not transparent with respect to each other. 使用host.BackColorTransparency = true,我能够使这些元素宿主对winforms GUI的背景透明,但是它们彼此之间仍然不透明。

I'm trying to be as descriptive as I can here. 我试图在这里尽可能地描述自己。 And since this is a work project I cannot display any proprietary information. 由于这是一个工作项目,因此我无法显示任何专有信息。 Please let me know if anyone needs any more information. 请让我知道是否有人需要更多信息。 Thank you for any help. 感谢您的任何帮助。

This MSDN article mentions a trick called 'bitmap copying'. MSDN文章提到了一个称为“位图复制”的技巧。

Actually this means the ElementHost paints the background of the owner control to its own drawing surface. 实际上,这意味着ElementHost将所有者控件的背景绘制到其自己的绘图表面上。 This is a simple 1:1 relation. 这是一个简单的1:1关系。 It does not take the overlapping controls into account. 它没有考虑重叠的控件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从WinForms ElementHost中托管的WPF UserControl获取对Window的引用 - How to get a reference to the Window from a WPF UserControl hosted in a WinForms ElementHost 如何在 Winforms 窗体和由 Winforms 窗体中的 elementhost 托管的 WPF 用户控件之间使用委托? - How to use a delegate between a Winforms Form and a WPF Usercontrol hosted by an elementhost in the Winforms form? WPF不在WinForms中的ElementHost中出现 - WPF Does Not Appear Within ElementHost in WinForms WinForms 中 WPF Elementhost 的自动调整大小无法正常工作 - Autosize of WPF Elementhost in WinForms not working properly WinForms 中的 WPF ElementHost 未收到鼠标点击 - WPF ElementHost in WinForms not receiving mouse clicks 变音符号和使用TAB更改Winforms ElementHost中WPF应用程序主机中的焦点 - Diacritics and using TAB to change focus in a WPF application hostet in Winforms ElementHost 如何在Winforms的工具箱中创建透明标签 - how to create transparent label in toolbox in winforms 如何在WinForm中刷新WPF ElementHost - how to refresh wpf elementhost inside winform 如何在WPF中创建自定义标签,然后在WinForms中使用 - How to create a custom label in WPF to be then used in WinForms 从C#Winforms上的elementhost中托管的RichText wpf控件获取文本 - Get text from RichText wpf control hosted in elementhost on Winforms in C#
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM