如何在图像上显示文本,使其始终可见(因为图像颜色是混合的且不可预测)?
我考虑了两个选择:
- 使文本边框为白色,而文本本身为黑色
- 使文字与图片相反地显示
第一个选项是首选,因为它看起来更坚固。
嵌入文本很简单:
<Grid>
<Image Source="{Binding ImageLink}" Width="110" />
<TextBlock Text="{Binding Description}"
HorizontalAlignment="Center"
VerticalAlignment="Center" />
</Grid>
更新于answer https://stackoverflow.com/questions/7888231/efficiently-display-text-on-image-in-wpf/7888677#7888677:
听起来是个好主意,但它行不通。
我尝试了你的代码,结果如下:
左图是当我设置Color
财产给White
and ShadowDepth
to 10
.
我这样做了,它有帮助:
<Style x:Key="AnnotationStyle" TargetType="TextBlock">
<Setter Property="Background" Value="#70FFFFFF" />
<Setter Property="FontWeight" Value="Bold" />
<Setter Property="HorizontalAlignment" Value="Center"/>
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="TextAlignment" Value="Center"/>
<Setter Property="TextWrapping" Value="Wrap"/>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="#CCFFFFFF" />
</Trigger>
</Style.Triggers>
</Style>
....
<TextBlock ... Style="{StaticResource AnnotationStyle}"/>
Here is what it looks like:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)