我有以下代码:
<TextBlock HorizontalAlignment="Center" TextWrapping="Wrap" Style="{StaticResource PhoneTextTitle1Style}" FontSize="65">
<Underline Foreground="DeepSkyBlue">
<Run Foreground="Turquoise" Text="{Binding SomeProp}"></Run>
</Underline>
</TextBlock>
我需要用绿松石色绘制文本,并使用其他颜色(“ DeepSkyBlue”)加下划线。我认为Run
element应该自己覆盖父控件的Foreground
属性,但是看起来这是一个错误的假设(实际上它覆盖了,但是我需要使用下划线来保持其他颜色)。WP8中有可能吗?如果是,我的样品出了什么问题?
编辑:在Pantelis和aloisdg的帮助下,工作代码如下所示:
<Grid Margin="0,0,0,10" HorizontalAlignment="Center">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Border BorderBrush="DeepSkyBlue" BorderThickness="0,0,0,1">
<TextBlock TextWrapping="Wrap" Style="{StaticResource PhoneTextTitle1Style}" FontSize="65">
<Run Foreground="Turquoise" Text="{Binding SomeProp}"></Run>
</TextBlock>
</Border>
</Grid>
我不确定这是否是最好的方法,但是您可以使用border
。
<Border BorderBrush="DeepSkyBlue" BorderThickness="0,0,0,1">
<!-- your text -->
</Border>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句