#942 – Text Justification in a TextBox

In typography, justification is the alignment of the edges of a block of text.  Text can be “flush left”, indicating that the left edges of the lines are aligned with each other and the right edges are ragged–i.e. not aligned.  Text can also be “flush right” (right ends of lines are aligned), “justified” (both edges line up), or centered (both edges ragged).

Like the TextBlock, the TextBox control allows setting justification using the TextAlignment property.  When set, text is continually adjusted to fulfill the desired alignment, as the user types.

  • Left – Left justify the text  (default)
  • Right – Right justify the text
  • Center – Center the text
  • Justify – Insert spaces between words to line up both edges of text  (only takes effect if line fills up available width and then wraps)
        <TextBox Margin="5" Height="100"
                 TextAlignment="Center"
                 TextWrapping="Wrap"
                 AcceptsReturn="True"
                 VerticalScrollBarVisibility="Auto"/>

942-001

About Sean
Software developer in the Twin Cities area, passionate about .NET technologies. Equally passionate about my own personal projects related to family history and preservation of family stories and photos.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: