default.aspx
Silverlight .NET Controls and CMS
Home
controls.aspx
Silverlight Controls
Controls
controls/rich_textbox.aspx
Silverlight Rich TextBox
Rich TextBox
Handling XAML Objects

Handling XAML Objects

One of the more unusual features of the RichTextBox is the ability to use XAML objects in your RichTextBox, by XAML it can be any object derived from FrameworkObject. In the example there is a standard CheckBox control along with a TextBoxPlus (The Liquid TextBox with password and Regular Expression validation support), both these controls can be copied around in the demo, however only the CheckBox retains it's IsChecked state, the Text property of the TextBoxPlus does not persist when pasting.

It's worth explaining here that when you paste RichText from control to control the RichText is generated from the actual visual XAML elements, i.e. the various TextBlock elements are serialized to RichText however only certain properties are maintained it is upto the developer to implement logic to maintain control state (such as IsChecked for the CheckBox and Text for the TextBoxPlus) for XAML elements.

Copying and Pasting content which contains a XAML object

In the above screenshot we have copied a selection of text containing a Checkbox which is checked and a TextBoxPlus containing text. The pasted version is immediately below and as you can see the Checkbox is pasted in a checked state, however the TextBoxPlus has lost it's text content.

ElementWriteToXML Event

This event is fired when you try to read the RichText property or perform a copy command, each XAML element in the RichText generates this event allowing you to inspect the control as it exists in the RichTextBox and optionally append additional parameters to the RichText representation of the XAML element.

ElementReadFromXML Event

This event is raised when you set the RichText property or perform a paste command, each XAML element in the RichText generates this event allowing you to access the instantiated XAML element as it is in the RichTextBox. Using this method you can set additional properties during a paste command allowing you to gracefully perform Copy/Paste commands in your RichTextBox whilst maintaining "ViewState" of your individual XAML controls.

Your Comments and Questions Answered

 You are not logged in. You need to login to post new messages, if you do not have a login you can register for free!

Be the first to post a comment or question.

 
This page is 14.2KB and was generated by the SilverPages CMS in 0.015 seconds. Total impressions: 572.