5

I'm porting an application from WPF to Silverlight and was saddened to read of the lack of FlowDocument support.

What is the best way in Silverlight then to display text with markup?

I just need the basics, e.g.

  • bold
  • italic
  • hyperlink
  • colors
  • font sizes

Added:

I don't mean a RichTextBox (as in the Vectorlight demo) but a way to format text on the application surface itself, like I can do with FlowDocument in WPF:

alt text
(source: deviantsart.com)

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
Edward Tanguay
  • 189,012
  • 314
  • 712
  • 1,047
  • confused by your edit - what does *on the application surface itself* actually mean? – Todd Main Mar 16 '10 at 22:04
  • e.g. not in a TextBox but in a TextBlock, i.e. not something that the user is supposed to edit, but just e.g. explanation text on the application – Edward Tanguay Mar 16 '10 at 22:06
  • 1
    here I just posted a video ("How to easily put bold...") explaining what I mean here: http://tanguay.info/dpwpf – Edward Tanguay Mar 16 '10 at 22:23
  • great way of showing what you mean. please see answer inline below. – Todd Main Mar 16 '10 at 23:53
  • The vector light demo shows the control being used to the full, however you should note that the toolbar etc is not part of the control, the basic control is just like a TextBox. This inturn can be styled and set to readonly hence it is possible to create content that looks identical to the sample you posted. However if I were doing this in SL4 I'd be looking at the RichTextBox rather than a free third-party item. – AnthonyWJones Mar 17 '10 at 10:16

4 Answers4

4

In Silverlight 3 Vectorlight's Free RichTextBox can do a pretty good job of what you need using HTML.

In Silverlight 4 you have the option of using the RichTextBox to represent your content.

AnthonyWJones
  • 187,081
  • 35
  • 232
  • 306
  • Note that RichTextArea was renamed to RichTextBox in SL4 RC – Timores Mar 16 '10 at 19:55
  • @Timores: Beta 2 has both, has the RichTextArea been dropped from the RC (I haven't got round to downloading it as yet)? – AnthonyWJones Mar 16 '10 at 20:34
  • @Timores: Looking at the Docs it looks like it has. – AnthonyWJones Mar 16 '10 at 20:37
  • I'm checking out the RichTextArea control in Silverlight 4, that looks promising: http://blogs.msdn.com/silverlight_sdk/archive/2009/12/03/have-you-checked-out-the-new-richtextarea-control.aspx – Edward Tanguay Mar 16 '10 at 21:50
  • @Anthony, the breaking changes description mentions that RichTextArea is now called RichTextBox. See the end of http://msdn.microsoft.com/en-us/library/cc645049(VS.96).aspx – Timores Mar 16 '10 at 23:10
  • @Edward, I think that Anthony's answer is correct. The RichTextBox control accepts Paragraph content (like FlowDocument) and can be made read-only – Timores Mar 16 '10 at 23:13
1

If you do get something like that up and running, msg me and maybe we can collaborate on bringing my "BindableFlowDocument" into the world of Silverlight. ;)

edit - wow, I must have gotten mixed up - my original answer was way off

JerKimball
  • 16,584
  • 3
  • 43
  • 55
1

Inline with the comments of SL4 RC's RichTextBox (RichTextArea, circa SL4 Beta), and with your example of importing marked up text, the SL4 RC RichTextBox will allow for an import of XAML formatted text - like string richText = MyRichContent.Xaml; on this page: http://timheuer.com/blog/#richtextbox. Details are listed here: http://msdn.microsoft.com/en-us/library/system.windows.controls.richtextbox.xaml(VS.96).aspx.

Todd Main
  • 28,951
  • 11
  • 82
  • 146
0

Just use the RichTextBox in Silverlight 4.0

Stan
  • 746
  • 1
  • 17
  • 35