简体   繁体   中英

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM