0

So here is the problem , i'have a label over a panel , the panel background color is set to Color.FromArgb(128,200,170,0) , so there is opacity. The label background color is set to Color.Transparent. But still the label text is surrounded by a band of the same color but darker.

Here is a picture :

opacity problem

Label properties : properties of label

Panel properties : enter image description here

Code executed after object created : code

eyilink
  • 35
  • 6
  • You should post your XAML code (sufficiently complete to replicate the issue). – M Kloster Jul 22 '22 at 08:22
  • i don't use WPF , it's all with the winforms graphical editor so there is no xaml code – eyilink Jul 22 '22 at 08:31
  • i can post the properties of each controls – eyilink Jul 22 '22 at 08:34
  • The Panel's BackColor is set to `Color.Transparent` in the PropertyGrid and it looks like it's painted with a HatchBrush (`HatchStyle.Percent50`?). Or is there something else, painted like that, over the Panel? A Label with BackColor set to `Color.Transparent` takes the color from its Parent (unless you [make it translucent](https://stackoverflow.com/a/51435842/7444103)) – Jimi Jul 22 '22 at 09:12
  • i dynamically in the code behind set the panel backcolor when this form is shown , i use the alpha property of Color.FromArgb to make this effect – eyilink Jul 22 '22 at 09:20
  • I will look to make it translucent to see if it works – eyilink Jul 22 '22 at 09:21
  • Setting the Panel's BackColor to a semi-transparent Color doesn't create that effect alone. If you didn't use a HatchBrush to paint the Panel, something else is painted like that (or contains a Bitmap). Unless the effect is generated by the quality of the image you have posted (but it doesn't look like). – Jimi Jul 22 '22 at 09:27
  • _a label over a panel_ This is not good enough. - The first question is: Is the Label actually __nested__ inside the Panel, ie is the Panel the Label's __Parent__? If so the transparency should work just fine, if not it won't.. Note the nesting happens when moving a control into a Panel but not when you move it with the cursor keys.. – TaW Jul 22 '22 at 11:23
  • Actually the panel is the label's parent , I dragged it with the mouse. And to be sure , I added Label.Parent = Panel ; in the code behind (constructor) – eyilink Jul 22 '22 at 11:38
  • OK, now to Jimi's questions: Is the Panel somehow painted on. Itas Backcolor is also transparent, so where does the pattern come from? – TaW Jul 22 '22 at 12:09
  • Also: _I will look to make it translucent to see if it works_ Well instead of a workaround better fix the actuall problem. Can you reproduce the effect in another form?? – TaW Jul 22 '22 at 12:17
  • Well, why don't you show us the code? – TaW Jul 22 '22 at 12:21
  • We can see white border around the panel , they are drawn on the paint event of the panel. The panel backcolor is originally transparent but when the form is loaded i change the backcolor of the panel to Color.FromArgb(128,168,143,0) , and the pattern comes from the alpha property – eyilink Jul 22 '22 at 12:37
  • So i create a popup , and I use the seTTitle property to change the backcolor of the header of the popup – eyilink Jul 22 '22 at 12:42
  • _the pattern comes from the alpha property_ Wat is the machine's color depth?? Is it not 32bpp? – TaW Jul 22 '22 at 12:53
  • i checked , the color depth is 8-bits – eyilink Jul 22 '22 at 13:06
  • Ah, well that should have been in your original question!! I'd rather not change my machine's settings, so I'm out. The recommended way would be to use the same Backcolor directly for Panel and Label. 8bit doesn't support transparency anyway.. – TaW Jul 22 '22 at 13:18
  • 1
    thanks , anyway the manager said that we give up on transparency , so problem solved – eyilink Jul 22 '22 at 13:55

0 Answers0