FlowDocument retrieved from external resource

I am trying to supplant some of the language in my WPF application, however I would like to use some degree of formatting as well.

My initial thought was to use a string resource that represented a FlowDocument or Paragraph, for example:

<FlowDocument>
  <Paragraph FontSize="16" Foreground="Blue">Some display text under content management</Paragraph>
</FlowDocument>

In the user interface, I am trying to bind this using IValueConverter:

<ContentControl Content="{Binding Path=CMSText,Source={StaticResource Resources},Converter={StaticResource flowDocConverter}"/>

In the converter:

StringReader sr = new StringReader(value.ToString());
XamlReader xamlReader = XamlReader.Create(sr);
return (FlowDocument)xamlReader.Parse();

but it continues to throw an exception in the return statement.

Is it possible to do this through binding?

And where am I mistaken in XamlReader?

EDIT

XamlParseException
"Unable to create unknown type" FlowDocument ". Line number" 1 "and line position" 2 ".

+3
source share
2 answers

FlowDocument Tag, NamePpace :

<FlowDocument xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:local="clr-namespace:MARS">
  <Paragraph FontSize="16" Foreground="Blue">Some display text under content management</Paragraph>
</FlowDocument>
+2

, xamlReader.Parse() FlowDocument ( , ).

- :

FlowDocument myFlowDoc = new FlowDocument();
myFlowDoc.Blocks.Add(new Paragraph(new Run(value)))

return myFlowDoc;

( , FlowDocument )

+1

All Articles