0 out of 1 rated this helpful - Rate this topic

RichTextBox.Xaml Property

Silverlight

Gets or sets a XAML representation of the content in the RichTextBox.

Namespace:  System.Windows.Controls
Assembly:  System.Windows (in System.Windows.dll)
public string Xaml { get; set; }

Property Value

Type: System.String
A String object that is a XAML representation of the content in the RichTextBox.

The XAML string returned by the Xaml property will only include the following elements:

Note Note:

Note that The XAML string returned by the Xaml property will not include any UIElement objects that are present in the content. The InlineUIContainer objects will be converted to empty Run objects.

The following table lists various elements and the corresponding properties that are included in the string returned by the Xaml property.

Element

Properties

TextElement

FontSize

FontFamily

Foreground

FontWeight

FontStyle

FontStretch

NoteNote:
The Xaml property only supports attribute values that can be represented as a string. For example, to set the Foreground property, you can only use a SolidColorBrush and not a LinearGradientBrush.

Run

FlowDirection

Text

Section

HasTrailingParagraphBreakOnPaste

Block

TextAlignment

Hyperlink

TargetName

NavigateUri

MouseOverForeground

MouseOverTextDecorations

The following code shows how the XAML is displayed by using the Xaml property.


//Set the xamlTb TextBox with the current XAML of the RichTextBox and make it visible. Any changes to the XAML made 
//in xamlTb is also reflected back on the RichTextBox. Note that the Xaml string returned by RichTextBox.Xaml will 
//not include any UIElement contained in the current RichTextBox. Hence the UIElements will be lost when we 
//set the Xaml back again from the xamlTb to the RichTextBox.
public void btnMarkUp_Checked(object sender, RoutedEventArgs e)
{
    if (btnMarkUp.IsChecked.Value)
    {
        xamlTb.Visibility = System.Windows.Visibility.Visible;
        xamlTb.IsTabStop = true;
        xamlTb.Text = rtb.Xaml;
    }
    else
    {
        rtb.Xaml = xamlTb.Text;
        xamlTb.Visibility = System.Windows.Visibility.Collapsed;
        xamlTb.IsTabStop = false;
    }

}


Silverlight

Supported in: 5, 4

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ