Transparent GradientStop in Silverlight is not exa

2019-08-30 02:22发布

问题:

I'm styling a simple graphical object in Silverlight, which is shown as a red rectangle with some white text on it; when the mouse hovers the rectangle, I want to show an overlay rectangle which fades from red to transparent, so that the text is only partially visible. My problem is, the LinearGradientBrush I'm using does not go from red to transparent but from red to some kind of semi-transparent white! I've reproduced the problem as follows:

<Grid x:Name="LayoutRoot" Background="Red">
<Grid.RowDefinitions>
    <RowDefinition/>
    <RowDefinition/>
</Grid.RowDefinitions>
<Grid>
    <Grid.Background>
        <LinearGradientBrush>
            <GradientStop Color="Transparent" Offset="0"/>
            <GradientStop Color="Red" Offset="1"/>
        </LinearGradientBrush>
    </Grid.Background>
</Grid>

In this case, you can easily see that the upper part of the grid is slightly lighter than the lower part, even though I've used the Transparent color constant. The result is identical if I use #00FFFFFF, while if I use #00xxxxxx, where xxxxxx is the RGB code of any color, the hue of the upper rectangle changes according to the color! Shouldn't the first two digits of the code represent the alpha channel? Why doesn't "00" mean full transparency? Any hint is appreciated.