TextBlock brush giving incorrect color

北城余情 提交于 2019-12-10 13:39:33

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!