[WPF Printing] Text alignment for the WPF document element (Run TextBlock Paragraph)

Source: Internet
Author: User

Recently developed WPF program, need to print, use the FlowDocument (this is equivalent to have a print template, and can be modified at any time, really very convenient). But it's a bit of a hassle to output tabular data, which is probably most of the time.

Because TableCell inside can not directly use Run or TextBlock, to add paragraph, this time the problem is, the TextAlignment property set above the paragraph, only when the text content directly written in the paragraph in effect ,

For the included TextBlock or run, even if you set their alignment directly, the content stays on the far left.

In this problem entangled half a day, search query a half-day data, finally understand. Paragraph is a drain layout element, the inner child element can only be one next to the reality. So in this case, replace the paragraph with Blockuicontainer and then set the alignment of run or TextBlock OK.

[WPF Printing] Text alignment for the WPF document element (Run TextBlock Paragraph)

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.