我的应用程序中有一个FlowDocumentReader控件。
<FlowDocumentReader Document="{Binding FlowDocument}" Style="{DynamicResource FlowDocumentStyle}" />下面是我如何将文本设置为FlowDocumentReader:
Paragraph paragraph = new Paragraph();
paragraph.Inlines.Add("some <b>book</b>");
FlowDocument.Blocks.Add(paragraph);问题是'book‘不像html那样显示,标签在wpf应用程序中是可见的。
我试着使用这个转换器:
http://code.msdn.microsoft.com/windowsdesktop/XAML-to-HTML-Conversion-ed25a674/view/SourceCode但在我的wpf应用程序中显示的文本如下所示:
<FlowDocument xml:space="preserve" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"><Paragraph>some <Run FontWeight="bold">book</Run></Paragraph></FlowDocument>再说一次,这并不大胆。我该怎么做呢?
发布于 2014-10-03 22:55:55
使用UI元素显示带格式的文本,并将其转换为段落的InlineUIContainer。
Paragraph paragraph = new Paragraph();
paragraph.Inlines.Add("some");
Label lb = new Label();
lb.FontWeight = FontWeights.Bold;
lb.Content = " Book";
paragraph.Inlines.Add(new InlineUIContainer(lb));
this.Doc.Document = new FlowDocument();
this.Doc.Document.Blocks.Add(paragraph); https://stackoverflow.com/questions/26177509
复制相似问题