Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/327.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/79.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在WP8中为不同颜色的文本加下划线?_C#_Xaml_Windows Phone 8_Windows Phone - Fatal编程技术网

C# 如何在WP8中为不同颜色的文本加下划线?

C# 如何在WP8中为不同颜色的文本加下划线?,c#,xaml,windows-phone-8,windows-phone,C#,Xaml,Windows Phone 8,Windows Phone,我有以下代码: <TextBlock HorizontalAlignment="Center" TextWrapping="Wrap" Style="{StaticResource PhoneTextTitle1Style}" FontSize="65"> <Underline Foreground="DeepSkyBlue"> <Run Foreground="Turquoise" Text="{Binding SomePr

我有以下代码:

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

我不确定这是最好的方法,但你可以使用一个


出于这些目的,我使用textEditions属性。 例如,在XAML中:

<TextBlock Name="undelinedTextBlock" 
           TextDecorations="Underline"
           Text="Underlined text"/>

请参阅此处的详细信息:

如果没有100%的把握,我认为这是不可能的。您可以使用stackpanel来表示textblock,并使用矩形、边框或任何其他适合情况的元素来绘制下划线。您的答案是正确的。使用Border+Grid解决了这个问题。请注意,该解决方案也适用于wp8.1 silverlight
<Border BorderBrush="DeepSkyBlue" BorderThickness="0,0,0,1">
    <!-- your text -->
</Border>
<TextBlock Name="undelinedTextBlock" 
           TextDecorations="Underline"
           Text="Underlined text"/>
 undelinedTextBlock.TextDecorations = TextDecorations.Underline;