I am doing the following to fill a rectangle with a certain o开发者_如何学编程pacity.
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;
精彩评论