flowdocument

Creating FlowDocument on BackgroundWorker thread

和自甴很熟 提交于 2019-12-11 12:59:22
问题 I have the need to generate dynamically generate a FlowDocument from a large set of data. Because the process takes several minutes, I'd like to perform the operation on a background thread rather than have the UI hang. However, I can't generate the FlowDocument on a non-UI thread otherwise attempts to insert rectangles and images cause run-time errors complaining that it's not STA thread. There are a couple of threads on StackOverflow which seem to involve the same problem I'm having:

How to initialize Paragraph Inlines

ⅰ亾dé卋堺 提交于 2019-12-11 10:48:23
问题 How can I initialize paragraph Inline with new InlineCollection? I defined InlineCollection and added Run elements with string to it. I tried to initialize this way ParagraphComponent.Inlines = _inlineCollection; However, I get error message that ParagraphComponent.Inline is readonly. 回答1: From the Remarks section of the Inlines property page on MSDN: Use the InlineCollection returned by this property to enumerate or manipulate the contents of a Paragraph element. So you could do this:

Controls in InlineUIContainer & BlockUIContainer always disabled in RichTextBox.Document

时光毁灭记忆、已成空白 提交于 2019-12-11 09:55:50
问题 For example if i have code like the following both Buttons are disabled: <RichTextBox> <FlowDocument> <BlockUIContainer> <Button Content="!"/> </BlockUIContainer> <Paragraph> <InlineUIContainer> <Button Content="!"/> </InlineUIContainer> </Paragraph> </FlowDocument> </RichTextBox> I have no idea why this is the case or what i can do to prevent this, obviously disabled buttons are not very useful so any help to resolve this would be appreciated. Edit: It turns out that the FlowDocument gets

WPF XAML Button Click handler in InlineUIContainer problem

 ̄綄美尐妖づ 提交于 2019-12-11 03:14:29
问题 I've got a FlowDocument which has some elements like so: <InlineUIContainer> <Button Click="Button_Click" Tag="123456789890"> <Image Source="Images\Image1.png" /> </Button> </InlineUIContainer> This is stored off in a .xaml file and gets loaded at some point by doing something like so: flowDocument = XamlReader.Load(xamlFile, parserContext) as FlowDocument; flowDocumentReader.Document = flowDocument; The loading fails with the following error: XamlParseException - Failed to create a 'Click'

Is it possible in WPF to get content of each DocumentPage by page number?

自作多情 提交于 2019-12-11 02:54:50
问题 I use DocumentPaginator to divide FlowDocument's text into pages. Is it possible to get content of each pages by page number after ComputePageCount()? If not, how can I do it in other way? Code: var flowDocument = this.Document; flowDocument.MaxPageHeight = this.MaxContentHeight; DocumentPaginator paginator = ((IDocumentPaginatorSource)flowDocument).DocumentPaginator; paginator.ComputePageCount(); 回答1: Yes, it is possible. Here is an example: MainWindow.xaml <Window x:Class="WpfApplication

Print flowdocument scroll viewer on multiple pages

房东的猫 提交于 2019-12-11 01:08:51
问题 I'm trying to print my FlowDocument (which is wrapped into a FlowDocumentScrollViewer) because I have a lot of texts/Textbox/combobox and the page height can become high ! I'm using this : PrintDialog printDialog = new PrintDialog(); if (printDialog.ShowDialog() == true) { Scrollvvv.Document.ColumnWidth = printDialog.PrintableAreaWidth; Scrollvvv.Document.ColumnGap = 0; printDialog.PrintDocument(((IDocumentPaginatorSource)Scrollvvv.Document).DocumentPaginator, ServicesLangue.RM.GetString(

How can I add multiple FlowDocumentReaders to a StackPanel?

为君一笑 提交于 2019-12-10 15:33:45
问题 Thanks to Leom's answer I was able to add a FlowDocument to a StackPanel by wrapping it in a FlowDocumentReader . But now I have two problems: it seems only the first FlowDocumentReader is added and the rest ignored there is an unwanted margin that I can't get rid of How can I add multiple FlowDocumentReaders to a StackPanel without the unwanted margin? alt text http://www.deviantsart.com/upload/1ndiqqe.png XAML: <Window x:Class="TestFlowdoc23432.Window1" xmlns="http://schemas.microsoft.com

How can I add a FlowDocument to a StackPanel?

做~自己de王妃 提交于 2019-12-10 15:26:29
问题 I created the following class in order to have an easy way to display formatted text in a WPF document. However this solution returns a FlowDocument , and I am having trouble integrating this FlowDocument in my current application in which I was simply adding TextBlocks to StackPanels and WrapPanels and Borders, etc. How can I add the FlowDocument objects that I create to my existing StackPanels, Borders, and WrapPanels? alt text http://www.deviantsart.com/upload/11jt33i.png using System

How can I prevent wrapping in a WPF FlowDocument in C# code?

二次信任 提交于 2019-12-10 14:49:14
问题 Studies have shown this is the way to prevent wrapping in, say, a Paragraph: <Paragraph> <TextBlock TextWrapping="NoWrap">unwrapping text</TextBlock> </Paragraph> How can I get the behavior in C# code? new Paragraph(new TextBlock() { Text = "unwrapping text", TextWrapping = TextWrapping.NoWrap }); Yields cannot convert from 'System.Windows.Controls.TextBlock' to 'System.Windows.Documents.Inline' because Paragraph's constructor is expecting an Inline. I can't seem to find a way to convert a

DocumentViewer to RichTextBox Binding Error

你。 提交于 2019-12-10 11:25:08
问题 I have an application with RichTextBox and DocumentViewer (placed in a TabControl), and I want to make something like "hot preview". I've binded DocumentViewer.Document property to RichTextBox.Document Binding: <DocumentViewer Document="{Binding Document, Converter={StaticResource FlowDocumentToPaginatorConverter}, ElementName=mainRTB, Mode=OneWay}" /> And this is Converter code: public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) {