StrikeThrough对TextBlock的影响

dca*_*tro 6 .net c# xaml microsoft-metro windows-store-apps

在Windows应用商店应用中,有没有办法对TextBlock的内容应用StrikeThrough效果?如果没有,RichTextBlock或任何类似的控件都可以.它是通过XAML还是通过编程方式(C#)无关紧要,但我更喜欢通过XAML,因此它会在设计器中显示.

我在微软的文档中找到了这个,但我不知道如何使用它:http: //msdn.microsoft.com/en-us/library/windows/apps/windows.ui.text.itextcharacterformat.strikethrough.aspx

Fas*_*ons 14

Windows应用商店应用程序具有自己的控件名称空间(System.Ui.Xaml.Controls).您将看到TextBlock for Windows Store应用程序没有TextDecoration属性:TextBlock文档.

"完整".Net 4.5 TextBlock确实具有TextDecoration属性:.Net 4.5 WPF TextBlock文档.

你可以这样做"hacky"这样:

    <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>
Run Code Online (Sandbox Code Playgroud)