Reputation: 69
I'm trying to show a popup when clicking on a cell in a grid. The popup has a usercontrol which contains an Element Host. I'm trying to make the popup transparent so I can see whats on the grid beneath but it doesn't seem to work. I'm using a ToolStripDropDown to show the popup.
Here is my code for the popup
ToolStripDropDown popup = new ToolStripDropDown();
popup.BackColor = Color.Transparent;
UserControl2 userControl = new UserControl2(popup);
userControl.Show();
popup.Margin = Padding.Empty;
popup.Padding = Padding.Empty;
ToolStripControlHost host = new ToolStripControlHost(userControl);
host.BackColor = Color.Transparent;
host.Margin = Padding.Empty;
host.Padding = Padding.Empty;
popup.Items.Add(host);
and here is the code for the UserControl itself
public partial class UserControl2 : UserControl
{
private ToolStripDropDown popup;
public UserControl2(ToolStripDropDown toolStrip)
{
InitializeComponent();
SetStyle(ControlStyles.SupportsTransparentBackColor, true);
this.BackColor = Color.Transparent;
popup = toolStrip;
this.elementHost1.BackColorTransparent = true;
}
}
and this is the result
Can someone tell what I'm doing wrong here, is there any way to show a transparent popup. The popup will eventually host a transparent WPF Control.
Thanks.
Upvotes: 1
Views: 854