flowdocument

WPF Handle links inside FlowDocument

天大地大妈咪最大 提交于 2019-12-24 08:47:02
问题 I'm building simple dictionary application using WPF. I'm using MVVM pattern, databinding and FlowDocument to display words to user. UI consists of 2 controls: ListBox and FlowDocumentScrollViewer. Dictionary data comes from XML file, format of this string may look like this <b>Word</b> - Some description. Another <i>description</i>. Reference <ref id="123">related word</ref> The order of HTML and reference elements is not defined. I parse HTML string, make it into XAML, then from XAML I

Sharing FlowDocuments between multiple RichTextBoxes

痞子三分冷 提交于 2019-12-24 04:30:16
问题 A WPF FlowDocument can only belong to a single RichTextBox . However, we'd like to use a single document which can be manipulated at different points (in space and time) in the UI. It will never happen that there are two RichTextBoxes simultaneously displaying a single document (and can't, because WPF will complain). Using a MemoryStream and XamlReader / Writer won't work here as we would like to retain a single document and reflect changes wherever it is used, so copying it every time is out

Changing inline in flowdocument

*爱你&永不变心* 提交于 2019-12-24 02:47:07
问题 I have a flowdocument like this: var mcFlowDoc = new FlowDocument(); var para = new Paragraph(); para.Inlines.Add(new Run("This is the first line.")); para.Inlines.Add(new Run("This is the second line.")); para.Inlines.Add(new Run("This is the third line.")); mcFlowDoc.Blocks.Add(para); richTextBox.Document = mcFlowDoc; I need to change the background of one of the lines by clicking on any part of that text. First of all I am trying to change the background of a given inline (regardless of

Insert a Hyperlink at a specified position in a WPF FlowDocument

*爱你&永不变心* 提交于 2019-12-24 00:37:39
问题 I'd like to insert a WPF Hyperlink element into a FlowDocument programmatically. The objective is to create a toolbar button that would take a run of text within a RichTextBox and replace it with a Hyperlink. It's the same sort of interface you see on the web for creating hyperlinks on wikis or in blogs (or on StackOverflow). I can find the TextRange of the selected text like this: TextRange tr = new TextRange( MyRichTextBox.Selection.Start, MyRichTextBox.Selection.End); And I'm attempting to

Paragraph formatting in a WPF RichTextBox?

夙愿已清 提交于 2019-12-23 17:21:03
问题 I need to apply paragraph formatting to a selection in a rich text box. My RTB will behave the same way as the rich text boxes on StackOverflow--the user can type text into the RTB, but they can also enter code blocks. The RTB will apply very simple formatting to the code block--it will change the font and apply a background color to the entire block, similar to what you see in the code block below. Changing the font is pretty straightforward: var textRange = new TextRange(rtb.Selection.Start

Getting a flowdocument from a xaml template file

爱⌒轻易说出口 提交于 2019-12-23 11:39:08
问题 I got a Xaml file that starts like this: <FlowDocument x:Name="flowDocument" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:Drawing="clr-namespace:System.Drawing;assembly=System.Drawing" Current solution uses a StremReader by referring to the physical path of the xaml file with the flowdocument and then parses data into the template. This is not a valid solution, so I need to get the flowdocument withouth

Printing a flowdocument with dynamic data in WPF

冷暖自知 提交于 2019-12-23 03:39:21
问题 I am trying to find a good way to print a flow document in WPF. What I want is to have a possibility to see how the document turns out as I design it, so therefore creating a pure FlowDocument as a XAML is out of the questions (as Visual Studio wont show the design view for it). So what I have done now is to create a window that contains a FlowDocument like this (some excessive parts have been removed to make the code more consise): <Window x:Class="MyNamespace.ProjectPrintout...> <Grid>

Accessing a WPF FlowDocument in a BackGround Process

核能气质少年 提交于 2019-12-22 16:15:37
问题 Accessing a WPF FlowDocument in the BackGround My question relates to accessing a UI object, in the background in WPF. I have seen dozens of sample apps, that all are simple, easy to follow, and 95% of which tell you how display a progress bar. That’s not quite what I want….. My problem is this: I want to perform a long task (or many long tasks) by accessing a FlowDocument in a RichTextBox. The exact task isn’t relevant here, but an example might be to scan through the document, and count the

Accessing a WPF FlowDocument in a BackGround Process

久未见 提交于 2019-12-22 16:12:13
问题 Accessing a WPF FlowDocument in the BackGround My question relates to accessing a UI object, in the background in WPF. I have seen dozens of sample apps, that all are simple, easy to follow, and 95% of which tell you how display a progress bar. That’s not quite what I want….. My problem is this: I want to perform a long task (or many long tasks) by accessing a FlowDocument in a RichTextBox. The exact task isn’t relevant here, but an example might be to scan through the document, and count the

Accessing a WPF FlowDocument in a BackGround Process

▼魔方 西西 提交于 2019-12-22 16:12:04
问题 Accessing a WPF FlowDocument in the BackGround My question relates to accessing a UI object, in the background in WPF. I have seen dozens of sample apps, that all are simple, easy to follow, and 95% of which tell you how display a progress bar. That’s not quite what I want….. My problem is this: I want to perform a long task (or many long tasks) by accessing a FlowDocument in a RichTextBox. The exact task isn’t relevant here, but an example might be to scan through the document, and count the