flowdocument

How do you get the selected text of a WPF FlowDocument?

霸气de小男生 提交于 2020-01-14 18:50:33
问题 I'm using .NET 3.5 I have a FlowDocument inside a FlowDocumentScrollViewer. I am not using RichTextBox. The FlowDocument comes with a number of "freebies", including text selection and a context menu for copy/paste. How can I find out what text is currently selected in the FlowDocument? I imagine that I could use ApplicationCommands.Copy to get the text into the clipboard and then read it from there, but I don't want to change the contents of the clipboard if I don't have to. There must be

How do you get the selected text of a WPF FlowDocument?

时光总嘲笑我的痴心妄想 提交于 2020-01-14 18:49:05
问题 I'm using .NET 3.5 I have a FlowDocument inside a FlowDocumentScrollViewer. I am not using RichTextBox. The FlowDocument comes with a number of "freebies", including text selection and a context menu for copy/paste. How can I find out what text is currently selected in the FlowDocument? I imagine that I could use ApplicationCommands.Copy to get the text into the clipboard and then read it from there, but I don't want to change the contents of the clipboard if I don't have to. There must be

WPF bug: TextRange.GetPropertyValue in RichTextBox

亡梦爱人 提交于 2020-01-06 14:48:35
问题 I have to retrieve the Foreground property of the selected text in a WPF RichtTextBox, but I think, there is a bug in the TextRange.GetPropertyValue function. I've written a simple application to test the error: <RichTextBox x:Name="rtfBox"> <RichTextBox.Document> <FlowDocument> <Paragraph> <Run>run run run</Run> <Hyperlink TargetName="http://stackoverflow.com">stackoverflow.com</Hyperlink> </Paragraph> </FlowDocument> </RichTextBox.Document> </RichTextBox> <Button Content="Click!" Height="28

WPF flowdocument with different first page size

ぐ巨炮叔叔 提交于 2020-01-06 03:48:05
问题 I have a flowdocument with repeating header/footer which is generated with custom DocumentPaginator . The problem is I need different header size for the first page or in the other words I need different PagePadding for the first page. A DocumentPaginator with repeating page header/footer was described many times (e.g. here or here) but never (?) for different size headers (very similar question without answer). My code snippet: public class ReportPaginator : DocumentPaginator { private

How to adjust the space between paragraph in a flow document by programming

安稳与你 提交于 2020-01-03 13:00:06
问题 I'm a beginer in C# Wpf and I want to make a flow document with few paragrah by programming. The problem is that there is a big space between pagraphs and i want to resize it to its minimum. I found a solution by using a Xml statement, but i want to make it by programming : <FlowDocument> <FlowDocument.Resources> <!-- This style is used to set the margins for all paragraphs in the FlowDocument to 0. --> <Style TargetType="{x:Type Paragraph}"> <Setter Property="Margin" Value="0"/> </Style> <

How to concatenate multiple FlowDocuments together into 1 FlowDocument

▼魔方 西西 提交于 2020-01-03 04:44:06
问题 I have multiple FlowDocuments that I would like to concatenate together. The method below doesn't have a return statement. What I would like to do is to turn the TextRange back into a FlowDocument. private FlowDocument Concatenate(FlowDocument source, FlowDocument target) { using(MemoryStream ms = new MemoryStream()) { TextRange tr = new TextRange(source.ContentStart, source.ContentEnd); tr.Save(ms, DataFormats.XamlPackage); ms.Seek(0, SeekOrigin.Begin); tr = new TextRange(target.ContentEnd,

Binding a list in a FlowDocument to List<MyClass>?

♀尐吖头ヾ 提交于 2020-01-01 09:13:13
问题 I have a FlowDocument containing stuff bound to my ViewModel like this: <FlowDocumentReader> <FlowDocument> <Paragraph> <Run Text="{Binding MyTextProperty}"/> </Paragraph> </FlowDocument> </FlowDocumentReader> Now I want to display a List of class using some kind of DataTemplate, but got no idea how to start. Say I got a class like: public MyClass { String Title {get;set;} String FlowText {get;set;} } public List<MyClass> MyList {get;set;} And I'd like to bind this to the FlowDocument List,

Displaying streaming rich text with WPF

我的未来我决定 提交于 2020-01-01 03:37:10
问题 I have a WPF application that connects via a socket to a device and gets streaming text data (approx 1 message per second). This data is then displayed on the UI. The user can create rules like "If the data contains 'abc' highlight the line" or "…make it bold" , so plain text output will not do, it needs to be "rich" text. My current solution to this is to have a FlowDocument in my ViewModel that contains the formatted output. The View has a FlowDocumentScrollViewer that is bound to the

Missing images in FlowDocument saved as XPS document

旧巷老猫 提交于 2019-12-30 18:27:24
问题 I am having some difficulties getting images contained in a FlowDocument to show when the FlowDocument is saved as an XPS document. Here is what I do: Create an image using the Image control of WPF. I set the image source bracketed by calls to BeginInit/EndInit. Add the image to the FlowDocument wrapping it in a BlockUIContainer. Save the FlowDocument object to an XPS file using a modified version of this code. If I then view the saved file in the XPS viewer, the image is not shown. The

Displaying a Multi-Paged FlowDocument with repeating Headers

 ̄綄美尐妖づ 提交于 2019-12-24 11:01:18
问题 I am trying to add Headers / footers to a WPF FlowDocument . I Found a solution on the Internet here that is using a custom Paginator Class to do this. Unfortunately this only works when printing out the Document, which is not what I intend to do. My Idea was to use a FlowDocumentPageReader or something similar with a custom paginator, but somehow I can't figure out how I would do that, maybe anyone can give me a hint in the right Direction. 回答1: If you are just displaying the FlowDocument