WPF vertical text and wpf text
--- Restore content start ---
I want to make a WPF text vertical layout. Used on the header of TabItem.
<TextBlock FontSize = "30" Text = "& # x0a; & # x0a; Cable & # x0a; Letter & # x0a; Interest"> </TextBlock>
The first is boring.
2. wpf Loader
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { string str = (string)value; //StringBuilder sb = new StringBuilder(); //for (int i = 0; i < str.Length; i++) //{ // if (i == str.Length - 1) // { // sb.Append(str[i]); // } // else // { // sb.Append(str[i]); // sb.Append(Environment.NewLine); // } //} //return sb.ToString();}
It is actually a line break.
3. At last, I found that this was the best solution.
Moderate text spacing
Http://zhidao.baidu.com/link? Url = Response
<TextBlock TextWrapping = "Wrap" Background = "Red" Padding = "0" LineHeight = "0.1" FontSize = "50" Width = "{Binding RelativeSource = {RelativeSource Self }, path = FontSize} "Text =" Nima ah ">
4. Conclusion:
I have the idea to use DrawingContext to draw the image and then set the rotation angle, which cannot be implemented.
Http://stackoverflow.com/questions/8815258/drawing-vertical-text-in-wpf-using-drawingcontext-drawtext
You can also setLayoutTransform. If the angle is set, the control is rotated, but the text is not.
For one thought, If the header of tabitem is of the object type, you can put it in listbox and set ItemsSource as a character array, which is a little troublesome.