本文介绍了在WPF TextBlock的竖排文字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以垂直显示在一个TextBlock文本,以便所有字母都在彼此(不与LayoutTransform旋转)?

Is it possible to display the text in a TextBlock vertically so that all letters are stacked upon each other (not rotated with LayoutTransform)?

推荐答案

还没有人提到了明显的和琐碎的方式来使用纯XAML垂直堆叠的任意字符串的字母(不旋转它们):

Nobody has yet mentioned the obvious and trivial way to stack the letters of an arbitrary string vertically (without rotating them) using pure XAML:

<ItemsControl
  ItemsSource="Text goes here, or you could use a binding to a string" />

这只是承认一个事实,即字符串是一个IEnumerable,因此可以ItemsControl的字符串作为一个单独的项目在对待每一个字符垂直排列的文字。为ItemsControl的默认面板是一个StackPanel中,这样的人物是垂直布局。

This simply lays out the text vertically by recognizing the fact that the string is an IEnumerable and so ItemsControl can treat each character in the string as a separate item. The default panel for ItemsControl is a StackPanel, so the characters are laid out vertically.

注:在过去的水平位置,垂直间距等precise的控制,ItemContainerStyle和ItemTemplate中属性可以在ItemsControl设置

Note: For precise control over horizontal positioning, vertical spacing, etc, the ItemContainerStyle and ItemTemplate properties can be set on the ItemsControl.

这篇关于在WPF TextBlock的竖排文字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-30 07:06