在一个TextBlock删除线效果 [英] StrikeThrough effect on a TextBlock

查看:812
本文介绍了在一个TextBlock删除线效果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Windows Store应用,有没有什么办法适用于一个TextBlock的内容删除线的效果呢?如果没有,一个RichTextBlock或任何类似的控制会做。这不要紧,如果它是通过XAML或以编程方式(C#),但是我preFER通过XAML所以它会显示在设计。

In a Windows Store App, is there any way to apply a StrikeThrough effect on a TextBlock's content? If there isn't, a RichTextBlock or any similar controls would do. It doesn't matter if it's through XAML or programmatically (C#), but I'd prefer through XAML so it would show in the designer.

我发现这其中微软的文档,但我不知道如何使用它: <一href="http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.text.itextcharacterformat.strikethrough.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.text.itextcharacterformat.strikethrough.aspx

I found this among Microsoft's documentation, but I don't know how to use it: http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.text.itextcharacterformat.strikethrough.aspx

推荐答案

Windows应用商店的应用程序有自己控制的命名空间(System.Ui.Xaml.Controls)。你会看到,文本块用于Windows应用商店的应用程序不具有textDecoration属性:<一href="http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.controls.textblock.aspx">TextBlock文档。

Windows Store apps have their own control namespace (System.Ui.Xaml.Controls). You'll see that the TextBlock for Windows Store apps doesn't have a TextDecoration property: TextBlock documentation.

满的.Net 4.5的TextBlock确实有一个textDecoration属性:。净4.5 WPF TextBlock的文档

The "full" .Net 4.5 TextBlock does have a TextDecoration property:.Net 4.5 WPF TextBlock Documentation.

您可以在哈克的方式,像这样做:

You can do this in a "hacky" way like so:

    <Grid Height="30">
        <TextBlock Text="This is a test" FontSize="22" Height="34" HorizontalAlignment="Center" Foreground="White"   />
        <Line Stretch="Fill" Stroke="white" StrokeThickness="2 " X1="1" Width="120" VerticalAlignment="Center"  HorizontalAlignment="Center"   />
    </Grid>

这篇关于在一个TextBlock删除线效果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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