SolidColorBrush with opacity on a black background

I am doing the following to fill a rectangle with a certain opacity.

 SolidColorBrush fillColor = new SolidColorBrush(myColor);
 fillColor.Opacity = 0.3;
 rectangle1.Fill = fillColor;

A rectangle is part of a user control that is on a black background. The problem is that I get opacity on a white background. How to change it as if the opacity was applied to the color on a black background.

The next color that I get to fill the green. enter image description here(like a white background) I need something like this. enter image description here(that is, as superimposed on a black background)

+5
source share
2 answers

- , , , , -. , XAML/VB visual studio 2017. :

Private Sub Hyper1_PointerEntered(sender As Object, e As RoutedEventArgs) Handles Hyper1.PointerEntered
    Hyper1.Background = New SolidColorBrush(Colors.Gold)
    Hyper1.Background.Opacity = 0.6
End Sub
+2

, :

myColor.A = 75; // 255 * 0.3 is approx. 75
SolidColorBrush fillColor = new SolidColorBrush(myColor);
rectangle.Fill = fillColor;
+2

All Articles