xaml - 半透明背景上的文本

标签 xaml transparency

这一定很简单,但我做不到:如果我将一个文本块放入容器中并使容器的不透明度 < 1,则无论我是否尝试在文本块中覆盖它,文本都会继承该不透明度。如何在半透明容器中保持文本 100% 不透明度?

<Grid x:Name="LayoutRoot">
    <Border Background="red" Opacity="0.5">
        <TextBlock Text="TextBlok" Opacity="1"/>
    </Border>
</Grid>

最佳答案

这会奏效吗?

<Border Background="#80FF0000">
    <TextBlock Text="TextBlok"/>
</Border>

将背景设置为透明,而不是整个边框元素...

关于xaml - 半透明背景上的文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/760501/

相关文章:

javascript - 领英关注按钮不透明

wpf - OxyPlot 在 VB.net 中不刷新

wpf - 如何从 ItemsControl 中的 ItemTemplate 获取控件?

wpf - 如何在 Mahapps.MetroWindow 中更改窗口标题的 FontWeigth

c# - 为什么样式 TargetType ="Window"在从 App.xaml 设置时不起作用?

wpf - 如何在WPF页面中隐藏导航栏

ios - 使 UINavigationBar 透明

user-interface - 窗口Ex : setting the background color to transparent

python - 如何在pygame中制作具有透明背景的表面

java - 透明面板上透明图像的旋转