问题
I have a TextBlock and a Rectangle, both sitting in an empty WPF4 window. The TextBlock's Foreground and the Rectangle's Fill are both set to a SolidColorBrush with value #80800000.
This is what it looks like:
The Rectangle's color is correct (a 50% transparent maroon) but the TextBlock gives a flat grey. What's going on?
EDIT: Here's the 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>
回答1:
Has this something to do with any of the additional icons you have at the top of your window? This code as expected for me.
screenshot
or are there any additional opacity setting in your code behind?
来源:https://stackoverflow.com/questions/6605534/textblock-brush-giving-incorrect-color