6

我有一个 TextBlock 和一个 Rectangle,它们都位于一个空的 WPF4 窗口中。TextBlock 的 Foreground 和 Rectangle 的 Fill 都设置为 SolidColorBrush,值为 #80800000。

这是它的样子:

在此处输入图像描述

Rectangle 的颜色是正确的(50% 透明栗色),但 TextBlock 给出的是纯灰色。这是怎么回事?

编辑:这是 XAML:

<Window x:Class="WpfApplication1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <TextBlock Foreground="#80800000" Height="100" HorizontalAlignment="Left" Margin="47,39,0,0" Text="TextBlock" VerticalAlignment="Top" Width="266" FontFamily="Arial" FontWeight="Bold" FontSize="56" />
        <Rectangle Fill="#80800000" Height="100" HorizontalAlignment="Left" Margin="71,174,0,0" Stroke="{x:Null}" VerticalAlignment="Top" Width="200" />
    </Grid>
</Window>
4

1 回答 1

0

这与窗口顶部的任何其他图标有关吗?这段代码符合我的预期。

截屏

或者您的代码中是否有任何额外的不透明度设置?

于 2011-07-07T04:32:53.550 回答