locked
How to generate the content of a RichTextBlock programmatically? RRS feed

  • Question

  • Hello,

    Is there a way to generate the contents of a RichTextBlock programmatically?

    It seems that the Blocks property of the Windows.UI.Xaml.Controls.RichTextBlock is read only.

    I hope that we are not supposed to generate xaml text from the code-behind to build a rich text content!

    Sunday, October 27, 2013 9:11 PM

Answers

  • Hi Stergiosls,

    Could you try something like: RichTextBlock.Blocks.Add(BlockItem) ? Thus you will be able to add some block into the RichTextBlock, is this what you mean by generate the content for RichTextBlock?

    Best Regards,

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    • Marked as answer by StergiosIs Monday, October 28, 2013 5:53 PM
    Monday, October 28, 2013 6:16 AM
    Moderator

All replies

  • Hi Stergiosls,

    Could you try something like: RichTextBlock.Blocks.Add(BlockItem) ? Thus you will be able to add some block into the RichTextBlock, is this what you mean by generate the content for RichTextBlock?

    Best Regards,

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    • Marked as answer by StergiosIs Monday, October 28, 2013 5:53 PM
    Monday, October 28, 2013 6:16 AM
    Moderator
  • Thank you James,

    I've missed the obvious! I was trying to create a BlockCollection and then set it to RichTextBlock.Blocks property.

    Regards,

    Stergios

    Monday, October 28, 2013 5:59 PM