在Windows Store应用程序中,有没有办法在TextBlock的内容上应用StrikeThrough效果?如果没有,则可以使用RichTextBlock或任何类似的控件。不管是通过XAML还是以编程方式(C#),但我更喜欢通过XAML,这样它就可以在设计器中显示出来。
我在微软的文档中找到了这个,但我不知道如何使用它:http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.text.itextcharacterformat.strikethrough.aspx
发布于 2012-10-08 05:03:43
Windows应用商店应用程序具有自己的控件命名空间(System.Ui.Xaml.Controls)。您将看到Windows Store应用程序的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>发布于 2012-10-08 04:43:47
毕竟,这似乎是不可能的:
“我们将不能在Windows8的XAML框架的最终版本中包含TextDecoration类。这意味着您将不能使用删除线功能,但您仍然可以通过下划线类为文本添加下划线。”
(http://social.msdn.microsoft.com/Forums/en-CA/winappswithcsharp/thread/cba0c363-60da-4e4e-9fc1-93f7c3658aff)
然而,微软正在做这件事:
“这是Windows8开发者预览版中XAML文本故事中的一个已知限制。从好的方面来看,这是一个计划中的改进领域,我们希望能解决这个问题。”
(http://social.msdn.microsoft.com/Forums/en-US/winappswithcsharp/thread/d5362fe2-48f6-448d-92ae-25216345c46d)
https://stackoverflow.com/questions/12772308
复制相似问题