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;
The rectangle is part of a user control that is on a Black background. The problem is that I am getting the opacity on a White background. How to change it as if opacity is applied on the color on a Black background.
The following is the color I get for a green color fill. (i.e as overlaid on white background) What I need is something like this. (i.e as overlaid on black background)
Question is years old I know but maybe this will help someone. This is what I did in XAML/VB visual studio 2017. This works great:
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
See if this works:
myColor.A = 75; // 255 * 0.3 is approx. 75
SolidColorBrush fillColor = new SolidColorBrush(myColor);
rectangle.Fill = fillColor;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With