gpt4 book ai didi

c# - TextBlock 上的删除线效果

转载 作者:太空狗 更新时间:2023-10-29 20:53:06 34 4
gpt4 key购买 nike

在 Windows 应用商店应用程序中,是否有任何方法可以对 TextBlock 的内容应用删除线效果?如果没有,RichTextBlock 或任何类似的控件都可以。它是通过 XAML 还是以编程方式 (C#) 并不重要,但我更喜欢通过 XAML,这样它就会显示在设计器中。

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

最佳答案

Windows 应用商店应用有自己的控件命名空间 (System.Ui.Xaml.Controls)。您会看到 Windows 应用商店应用程序的 TextBlock 没有 TextDecoration 属性:TextBlock documentation .

“完整的”.Net 4.5 TextBlock 确实有一个 TextDecoration 属性:.Net 4.5 WPF TextBlock Documentation .

你可以像这样以“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>

关于c# - TextBlock 上的删除线效果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12772308/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com