Tag: flowdocument

replaceXamlPackage中的文本

我在RichTextBox中有一些文本。 此文本包含标签,例如:[@标签名称!]。 我想用数据库中的一些数据replace这些标签,而不会丢失格式(字体,颜色,图像等)。 我创build了一个方法: void ReplaceTagsWithData(FlowDocument doc) { FileStream fs = new FileStream("tmp.xml", FileMode.Create); TextRange trTextRange = new TextRange(doc.ContentStart, doc.ContentEnd); trTextRange.Save(fs, DataFormats.Xaml); fs.Dispose(); fs.Close(); StreamReader sr = new StreamReader("tmp.xml"); string rtbContent = sr.ReadToEnd(); MatchCollection mColl = Regex.Matches(rtbContent, string.Format(@"\{0}+[a-zA-Z]+{1}", prefix, postfix)); foreach (Match m in mColl) { string colname = m.Value.Substring(prefix.Length, (int)(m.Value.Length – (prefix.Length + postfix.Length))); […]

如何在WPF应用程序中生成FlowDocument的“打印预览”?

我的各种WPF应用程序显示FlowDocument的。 我可以使用打印WPF FlowDocument 的答案中描述的方法来打印它们。 现在我想添加一个“打印预览”function。 在正常情况下,我正在打印显示在窗口中的FlowDocument,所以我不需要打印预览。 但是在某些情况下,要打印的FlowDocument在内存中即时构build。 在这些情况下,我想在打印之前显示它。 现在,我当然可以popup一个新窗口并显示FlowDocument,但是 我希望预览真正感觉它是打印操作的一部分,而不是应用程序中的另一个窗口。 我不想在FlowDocumentScrollViewer中使用正常的FlowDocument。 它不是“任何规模”,而是需要限制在纸张的大小,具体的HxW比率和分页。 build议? 我应该只使用一个标准的窗口,在这种情况下,如何确保FlowDocument是在适当的比例? 有没有更多的“集成”的方式来作为Windows的一部分的PrintDialog UI的范围内预览? 谢谢