2011-10-12 64 views
5

我在做以下操作來填充具有某種不透明度的矩形。黑色背景上有不透明度的SolidColorBrush

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

矩形是在黑色背景上的用戶控件的一部分。問題是我在白色背景上獲得不透明度。如何改變它,就像在黑色背景上的顏色上應用了不透明度一樣。

以下是我爲綠色填充獲得的顏色。 enter image description here(即覆蓋在白色背景上)我需要的是這樣的東西。 enter image description here(即作爲覆蓋在黑色背景)

回答

2

問題是歲,但我知道也許這將幫助別人。這是我在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; 
+0

不工作仍然。 – devnull