LinearGradientBrush 到 Transparency 显示白色背景
LinearGradientBrush to Transparency shows white background
我有 background
颜色 #424242
和 ListBox
以及一些内容..
我想在控件顶部有一个从 #424242
到 Transparent
的 LinearGradientBrush。问题是,我得到了白色背景颜色:
如果我用 #00000000
替换 Transparent
我有一个 darker/black 颜色:
XAML代码
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="136*"/>
<RowDefinition Height="203*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<StackPanel Orientation="Vertical" Grid.Column="0" Grid.Row="0" HorizontalAlignment="Center">
<TextBlock Text="Transparent to #424242"></TextBlock>
<TextBlock Text="Transparent to #424242"></TextBlock>
<TextBlock Text="Transparent to #424242"></TextBlock>
<TextBlock Text="Transparent to #424242"></TextBlock>
<TextBlock Text="Transparent to #424242"></TextBlock>
<TextBlock Text="Transparent to #424242"></TextBlock>
<TextBlock Text="Transparent to #424242"></TextBlock>
<TextBlock Text="Transparent to #424242"></TextBlock>
<TextBlock Text="Transparent to #424242"></TextBlock>
<TextBlock Text="Transparent to #424242"></TextBlock>
<TextBlock Text="Transparent to #424242"></TextBlock>
<TextBlock Text="Transparent to #424242"></TextBlock>
<TextBlock Text="Transparent to #424242"></TextBlock>
<TextBlock Text="Transparent to #424242"></TextBlock>
<TextBlock Text="Transparent to #424242"></TextBlock>
</StackPanel>
<Rectangle Grid.Column="0" Grid.Row="0">
<Rectangle.Fill>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="Transparent" Offset="0"/>
<GradientStop Color="#424242" Offset="1"/>
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
<StackPanel Orientation="Vertical" Grid.Column="1" Grid.Row="0" HorizontalAlignment="Center">
<TextBlock Text="#00000000 to #424242"></TextBlock>
<TextBlock Text="#00000000 to #424242"></TextBlock>
<TextBlock Text="#00000000 to #424242"></TextBlock>
<TextBlock Text="#00000000 to #424242"></TextBlock>
<TextBlock Text="#00000000 to #424242"></TextBlock>
<TextBlock Text="#00000000 to #424242"></TextBlock>
<TextBlock Text="#00000000 to #424242"></TextBlock>
<TextBlock Text="#00000000 to #424242"></TextBlock>
<TextBlock Text="#00000000 to #424242"></TextBlock>
<TextBlock Text="#00000000 to #424242"></TextBlock>
<TextBlock Text="#00000000 to #424242"></TextBlock>
<TextBlock Text="#00000000 to #424242"></TextBlock>
<TextBlock Text="#00000000 to #424242"></TextBlock>
<TextBlock Text="#00000000 to #424242"></TextBlock>
<TextBlock Text="#00000000 to #424242"></TextBlock>
</StackPanel>
<Rectangle Grid.Column="1" Grid.Row="0">
<Rectangle.Fill>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#00000000" Offset="0"/>
<GradientStop Color="#424242" Offset="1"/>
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
<StackPanel Orientation="Vertical" Grid.Column="2" Grid.Row="0" HorizontalAlignment="Center">
<TextBlock Text="Hello World"></TextBlock>
<TextBlock Text="Hello World"></TextBlock>
<TextBlock Text="Hello World"></TextBlock>
<TextBlock Text="Hello World"></TextBlock>
<TextBlock Text="Hello World"></TextBlock>
<TextBlock Text="Hello World"></TextBlock>
<TextBlock Text="Hello World"></TextBlock>
<TextBlock Text="Hello World"></TextBlock>
<TextBlock Text="Hello World"></TextBlock>
<TextBlock Text="Hello World"></TextBlock>
<TextBlock Text="Hello World"></TextBlock>
<TextBlock Text="Hello World"></TextBlock>
<TextBlock Text="Hello World"></TextBlock>
<TextBlock Text="Hello World"></TextBlock>
<TextBlock Text="Hello World"></TextBlock>
</StackPanel>
<Rectangle Grid.Column="2" Grid.Row="0" Opacity="0">
<Rectangle.Fill>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#424242" Offset="0"/>
<GradientStop Color="#424242" Offset="1"/>
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
</Grid>
</Grid>
我有答案:只需使用与 Alpha 0% 相同的颜色
<Rectangle.Fill>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FF424242" Offset="1"/>
<GradientStop Color="#00424242"/>
</LinearGradientBrush>
</Rectangle.Fill>
我有 background
颜色 #424242
和 ListBox
以及一些内容..
我想在控件顶部有一个从 #424242
到 Transparent
的 LinearGradientBrush。问题是,我得到了白色背景颜色:
如果我用 #00000000
替换 Transparent
我有一个 darker/black 颜色:
XAML代码
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="136*"/>
<RowDefinition Height="203*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<StackPanel Orientation="Vertical" Grid.Column="0" Grid.Row="0" HorizontalAlignment="Center">
<TextBlock Text="Transparent to #424242"></TextBlock>
<TextBlock Text="Transparent to #424242"></TextBlock>
<TextBlock Text="Transparent to #424242"></TextBlock>
<TextBlock Text="Transparent to #424242"></TextBlock>
<TextBlock Text="Transparent to #424242"></TextBlock>
<TextBlock Text="Transparent to #424242"></TextBlock>
<TextBlock Text="Transparent to #424242"></TextBlock>
<TextBlock Text="Transparent to #424242"></TextBlock>
<TextBlock Text="Transparent to #424242"></TextBlock>
<TextBlock Text="Transparent to #424242"></TextBlock>
<TextBlock Text="Transparent to #424242"></TextBlock>
<TextBlock Text="Transparent to #424242"></TextBlock>
<TextBlock Text="Transparent to #424242"></TextBlock>
<TextBlock Text="Transparent to #424242"></TextBlock>
<TextBlock Text="Transparent to #424242"></TextBlock>
</StackPanel>
<Rectangle Grid.Column="0" Grid.Row="0">
<Rectangle.Fill>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="Transparent" Offset="0"/>
<GradientStop Color="#424242" Offset="1"/>
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
<StackPanel Orientation="Vertical" Grid.Column="1" Grid.Row="0" HorizontalAlignment="Center">
<TextBlock Text="#00000000 to #424242"></TextBlock>
<TextBlock Text="#00000000 to #424242"></TextBlock>
<TextBlock Text="#00000000 to #424242"></TextBlock>
<TextBlock Text="#00000000 to #424242"></TextBlock>
<TextBlock Text="#00000000 to #424242"></TextBlock>
<TextBlock Text="#00000000 to #424242"></TextBlock>
<TextBlock Text="#00000000 to #424242"></TextBlock>
<TextBlock Text="#00000000 to #424242"></TextBlock>
<TextBlock Text="#00000000 to #424242"></TextBlock>
<TextBlock Text="#00000000 to #424242"></TextBlock>
<TextBlock Text="#00000000 to #424242"></TextBlock>
<TextBlock Text="#00000000 to #424242"></TextBlock>
<TextBlock Text="#00000000 to #424242"></TextBlock>
<TextBlock Text="#00000000 to #424242"></TextBlock>
<TextBlock Text="#00000000 to #424242"></TextBlock>
</StackPanel>
<Rectangle Grid.Column="1" Grid.Row="0">
<Rectangle.Fill>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#00000000" Offset="0"/>
<GradientStop Color="#424242" Offset="1"/>
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
<StackPanel Orientation="Vertical" Grid.Column="2" Grid.Row="0" HorizontalAlignment="Center">
<TextBlock Text="Hello World"></TextBlock>
<TextBlock Text="Hello World"></TextBlock>
<TextBlock Text="Hello World"></TextBlock>
<TextBlock Text="Hello World"></TextBlock>
<TextBlock Text="Hello World"></TextBlock>
<TextBlock Text="Hello World"></TextBlock>
<TextBlock Text="Hello World"></TextBlock>
<TextBlock Text="Hello World"></TextBlock>
<TextBlock Text="Hello World"></TextBlock>
<TextBlock Text="Hello World"></TextBlock>
<TextBlock Text="Hello World"></TextBlock>
<TextBlock Text="Hello World"></TextBlock>
<TextBlock Text="Hello World"></TextBlock>
<TextBlock Text="Hello World"></TextBlock>
<TextBlock Text="Hello World"></TextBlock>
</StackPanel>
<Rectangle Grid.Column="2" Grid.Row="0" Opacity="0">
<Rectangle.Fill>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#424242" Offset="0"/>
<GradientStop Color="#424242" Offset="1"/>
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
</Grid>
</Grid>
我有答案:只需使用与 Alpha 0% 相同的颜色
<Rectangle.Fill>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FF424242" Offset="1"/>
<GradientStop Color="#00424242"/>
</LinearGradientBrush>
</Rectangle.Fill>