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.
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!