Reputation: 854
I have this XAML rectangle -
<Rectangle x:Name="rctRGB"
HorizontalAlignment="Left"
Margin="100,316,0,0"
Stroke="Black"
VerticalAlignment="Top" Height="100" Width="702"/>
I have three slider bars, and am trying to use these to set the RGB values respectively. This event is firing correctly, but the rectangle just simply does not change color.
private void FillRectangle()
{
Windows.UI.Color c = new Windows.UI.Color();
c.R = Convert.ToByte(sldRed.Value);
c.G = Convert.ToByte(sldGreen.Value);
c.B = Convert.ToByte(sldBlue.Value);
Brush b = new SolidColorBrush(c);
rctRGB.Fill = b;
}
I am pretty lost why this is not happening; do I have to force the rectangle to redraw itself? If so, how do I do that? Or is something else wrong?
Thank you !
(Note, this is a Windows 8 Store project; I do not know if that is relevant or not as I have not previously worked in WPF/XAML).
Upvotes: 0
Views: 2534
Reputation: 23784
You haven't set the alpha channel, which is defaulting to 0, so your color is there, it's just transparent.
Add another slider for the alpha channel or just add the following to your code:
c.A = 255;
Upvotes: 2