如何在 WP8 中用不同颜色的文本下划线? [英] how to underline text with different color in WP8?

查看:22
本文介绍了如何在 WP8 中用不同颜色的文本下划线?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码:

 <TextBlock HorizontalAlignment="Center" TextWrapping="Wrap" Style="{StaticResource PhoneTextTitle1Style}" FontSize="65">
       <Underline Foreground="DeepSkyBlue">
            <Run Foreground="Turquoise" Text="{Binding SomeProp}"></Run>
       </Underline>
 </TextBlock>

我需要的是用绿松石色绘制我的文本并使用其他颜色 - DeepSkyBlue"在它的下划线.我认为 Run 元素应该为自己覆盖父控件 Foreground 属性,但看起来这是错误的假设(实际上它会覆盖但我需要下划线以保持其他颜色).在 WP8 中可以吗?如果是,我的样本有什么问题?

What I need is to paint in turquoise color my text and underline it using other color - "DeepSkyBlue". I thought Run element should overwrite the parent control Foreground property for itself but it looks like it was wrong assumption (actually it overwrites but I need underline to stay other color). Is it possible in WP8? If yes, what is wrong with my sample?

Pantelisaloisdg 工作代码如下所示:

with the help of the Pantelis and aloisdg the working code looks like this:

        <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.

I am not sure this is the best way to do it, but you can use a border.

<Border BorderBrush="DeepSkyBlue" BorderThickness="0,0,0,1">
    <!-- your text -->
</Border>

这篇关于如何在 WP8 中用不同颜色的文本下划线?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆