WPF vertical text and wpf text

Source: Internet
Author: User

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.

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.