Saving Image embedded in Silverlight RichTextBox
I am currently working on a Silverlight project and I am using RichTextBox. User are allowed to drag and开发者_高级运维 drop images on to the RTB. I know that the Xaml property a Silverlight RichTextBox doesn't not include any UIElement objects that are present in the content and I need to save the content of this RTB and later load it. Does anyone know of a way to achieve this? Thanks.
You're probably better off traversing the all of the Inlines in the RTB. The InlineUIContainers are Inlines so you can handle those however you'd like.
Your basic strategy should look something like: Get the Blocks property of the RTB, find all the Paragraphs. Get the Inlines on each Paragraph. For each inline: handle a Run and save as Text. handle InlineUIContainer and save as however you'd like. Handle a Span as a recursive call to find the child Inlines.
If you want to save formatting on the Runs, then you'll have even more code for that.
It's not nearly as easy as using the Xaml property but it's really the only way to handle controls in InlineUIContainers.
精彩评论