You can format text in a RichTextBox
at the paragraph-level and inline-level at runtime. The following example shows how you can right-align the entire contents of the RichTextBox
within a Button.Tap
event handler:
void Button_Tap(object sender, System.Windows.Input.GestureEventArgs e)
{
foreach (Block block in richTextBox1.Blocks)
{
block.TextAlignment = TextAlignment.Right;
}
}
Figure 6.11 shows the contents of a RichTextBox
after it has been right-aligned via a Button
placed within the Paragraph
.
The source for this section is located in the RichTextBoxView page in the ControlExamples directory of the WPUnleashed.Examples project in the downloadable sample code.
While the RichTextBox
control for Windows Phone lacks the ability to be edited by the user, it does allow you to blend text and rich content in a way that is easier than, for example, nesting TextBlocks
and other elements within a StackPanel
.
18.116.87.250