flowdocument

Bug in FlowDocument Table?

∥☆過路亽.° 提交于 2019-12-06 13:02:54
first of all, Width calculation of FlowDocuments TableColumns is a mess. but this is rather ridiculous: <FlowDocumentScrollViewer> <FlowDocument> <Paragraph>text that's not visible</Paragraph> <Table BorderThickness="0.7559" > <Table.Columns> <TableColumn Width="100" /> </Table.Columns> <TableRowGroup> <TableRow> <TableCell/> </TableRow> </TableRowGroup> </Table> </FlowDocument> </FlowDocumentScrollViewer> this actually shows nothing. So the table seems to mess up the whole document. If I either take out the Width="100" or change the Borderthickness to something less precise like

Accessing a WPF FlowDocument in a BackGround Process

落爺英雄遲暮 提交于 2019-12-06 08:16:50
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 number of times a particular word appears, or how many red characters there are……. In a long document,

How can I create subclass of class Inline ? (the one used in FlowDocument)

天涯浪子 提交于 2019-12-06 01:59:28
问题 In WPF I would like to create custom Inline implementation. From documentation of Inline: "An abstract class that provides a base for all inline flow content elements." Classes like Figure, Run or Span inherit from Inline. My custom class inheriting from Inline would be something like '2 lined Run'. I have special needs for flow of document and this seems to be the only way. However I don't know where to start: Inline does not define any members! It is abstract class so it is meant to be

Detect if a RichTextBox is empty

ⅰ亾dé卋堺 提交于 2019-12-05 14:07:20
问题 What is the best way to detect if a WPF RichTextBox/FlowDocument is empty? The following works if only text is present in the document. Not if it contains UIElement's new TextRange(Document.ContentStart, Document.ContentEnd).IsEmpty 回答1: You could compare the pointers, which is not all too reliable: var start = rtb.Document.ContentStart; var end = rtb.Document.ContentEnd; int difference = start.GetOffsetToPosition(end); This evaluates to 2 if the RTB is loaded, and 4 if content has been

Highlight parts of text in FlowDocument

假装没事ソ 提交于 2019-12-05 10:02:42
I want to highlight some parts of text in a FlowDocument based on the search results. What I am doing is getting the indexes where the searched word occures in the text of the FlowDocument and then apply background color on the text range starting at the found index, ending at the found index + search word length. TextRange content = new TextRange(myFlowDocument.ContentStart, myFlowDocument.ContentEnd); List<int> highlights = GetHighlights(content.Text, search); foreach (int index in highlights) { var start = myFlowDocument.ContentStart; var startPos = start.GetPositionAtOffset(index); var

FlowDocument loses ClearType in child elements when placed in window with custom glass

对着背影说爱祢 提交于 2019-12-05 08:50:01
So the new WPF 4 text rendering looks great, but enabling the aero glass effect on a window requires that you change the background to transparent, which of course disables ClearType rendering. Using the provided RenderOptions.ClearTypeHint=Enabled allows you to designate child elements to reenable ClearType rendering from that point in the tree. I've found a few other topics that talk about doing this for the ScrollViewer used internally inside RichTextBox and FlowDocumentScrollViewer, and creating a custom style does indeed fix it so that my FlowDocument gets ClearType rendering again.

WPF/XAML: Typography.Capitals seems to have no effect

与世无争的帅哥 提交于 2019-12-05 07:30:25
All of these bits of text look the same, but I am trying to get them to look different. I want small caps text. What am I missing here to get the small caps typography effect to work? To reproduce this, open Visual Studio 2008, Do File|New Project, create a new Windows|WPF application, paste the mark-up below into Window1.xaml, then run it. <Window x:Class="WpfApplication1.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window1" Height="300" Width="300"> <Grid> <FlowDocumentReader> <FlowDocument>

How can I keep a table together in a FlowDocument?

a 夏天 提交于 2019-12-05 02:40:57
问题 I thought if I place the Table in a Paragraph that I could use the KeepTogether attribute to keep the table together. The table is used for the totals of a report and the client does not want them broken over two pages. Imagine that! There are 5 rows in the table and I am going crazy not knowing what to try next. Last line of code: myFlowDocument.Blocks.Add(footerParagraph); The output of footerParagraph begins with: <Paragraph KeepTogether="True"> <Floater HorizontalAlignment="Center">

How Can I Get a TextPointer from a mouse click in a FlowDocument

和自甴很熟 提交于 2019-12-05 00:55:32
问题 I would like to get the word that a user has clicked on in a FlowDocument. I am currently adding an event handler to every Run in the document and iterating through the TextPointers in the Run that was clicked, calling GetCharacterRect() on each one and checking if the rectangle contains the point. However, when the click occurs near the end of a long Run this takes > 10 seconds. Is there any more efficient method? 回答1: I'd say the easiest way is to use the Automation interfaces: using System