flowdocument

How do I save RichTextBox content into SQL varbinary (byte array) column?

Hi I want to save content of a RichTextBox to varbinary (= byte array) in XamlPackage format. I need technicial advise on how to it. I actually need to know how to convert between FlowDocument to byte array. Is it even recommended to store it as varbinary, or this is a bad idea? Update Code snippet: ///Load byte[] document = GetD...

Detect FlowDocument Change and Scroll

I want to detect (preferably through an event) when any content is added, changed, etc. in a FlowDocument and when it does I want to cause a FlowDocumentScrollViewer displaying the FlowDocument to automatically scroll to the end. ...

Get controls by position within wpf FlowDocumentScrollViewer

I have a FlowDocument with much content inside. I need to get the controls that are currently in the visible area. with DependencyObject obj = FlowDocumentScrollViewerCtrl; do { if (VisualTreeHelper.GetChildrenCount(obj) > 0) { obj = VisualTreeHelper.GetChild(obj as Visual, 0); } } while (!(obj is ScrollViewer)); ...

making a simple search function, making the cursor jump to (or highlight) the word that is searched for.

Dear community. I have now used way too long time, trying to figure out a problem, which I didn't think would be that hard. Here is the deal: I am writing a small application using C# and WPF. I have a RichTextBox containing a FlowDocument. I have added a small textbox and a button below my richtextbox. The user then types in the w...

Copying one FlowDocument to Second FlowDocument

Hi, How can i copy the contents of one FlowDocument to another FlowDocument below is what i tryed foreach (var blk in fd1.Blocks) { fd2.Blocks.Add(blk); } fd1 is FlowDocument1 and fd2 is FlowDocument2. But i get the below error. Collection was modified; enumeration operation may not execute. Thanks Arvind ...

FlowDocument contents as text

What is the best way to get back the XAML/XML value of a FlowDocument? I noticed there isn't a .Value, .Text, .Caption, .ToXml(), etc... UDPATE: I'd like to be able to get access to it initially to serialize to disk or database. Treat it as its own document format. Later translating it to other formats would be nice. Also been wonder...

Dynamic document: WPF Combine bound text in a static inline FlowDocument.

Hello, I am trying to achieve something like the follwing: This is a WPF Flow Document shown to user. This has been generated by user Richard Richardson at 01/01/01 23:15:00. Blah blah blah (another 466 lines)... End of message. I want this date and the user name and 466 (and another gazillion literal texts) to come from Bi...

WPF flowdocument element names are reset?

I have a flowdocument with a named Span" test1" which I want to replace the contents of programmatically TextRange tr = new TextRange(this.test1.ContentStart,this.test1.ContentEnd); Run run = this.test1.Inlines.First() as Run; run.Text = "replaced text"; This works, however the problem is when doing the update the name of the span...

WPF: Printing a FlowDocument

I'm trying to get a FlowDocument to print. After spending much of the day trying multiple pages I failed and opted for something simpler, but I'm now at a loss to explain when text isn't output to the page. This has to be something I've got snowblind to I think. There are two tables below, placing a converter on both shows that the value...

WPF FlowDocumentReader and FlowDocument Screen Reader (NVDA) Acccessibility

I am using a FlowDocumentReader to display FlowDocuments in a .NET 3.5 WPF application (the FlowDocuments have help/info/notes that are displayed based on user choices in the ui). I assumed that the FlowDocumentReader contents would be read/recognized by a Screen Reader (I am testing with NVDA on Windows 7) - but when the reader gets fo...

WPF FlowDocument: force calculation of height etc. "off screen"

My target: a DocumentPaginator which takes a FlowDocument with a table, which splits the table to fit the pagesize and repeat the header/footer (special tagged TableRowGroups) on every page. For splitting the table I have to know the heights of its rows. While building the FlowDocument-table by code, the height/width of the TableRows a...

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

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...

Navigating to a specific fragment in a flow document from code behind

Hi, I have a WPF page used as an input form which contains a number of controls on one side, and a flow document reader on the other. I want to set the content of this document reader to a specific part of a flow document which is loaded when the form is loaded, (via a loaded event). I have found an article explaining how to do this,...

Bookmarking WPF's FlowDocumentReader

I'm trying to save and restore the position of the document within a FlowDocumentReader to create a bookmark feature. There doesn't appear to be any seeking or search feature build in that is publicly accessible, leaving me with the following options: Use FlowDocumentPageViewer instead, saving the page each time the window is resized a...

My custom WPF RIchTextBox will not accept user input, even after setting IsReadOnly=false

I have written a custom Bindable RichText Box, so I can bind to the Document property. However, as soon as I set my document content, the only keyboard input it accepts is the backspace key (???). No other keyboard input is acknowledged (including the arrow keys). Any ideas? Here is the code of my BindableRTB class: Imports System.W...

Programmatic WPF FlowDocument generation and dynamic styles.

I'm generating a FlowDocument in code but I want it to apply dynamic styles defined in the resource dictionary. Even though I set the key using SetResourceReference, it seems like the resource lookup doesn't occur once I add the TextElements to the FlowDocument. My guess is that just adding the control to the document doesn't hook u...

How can I add a FlowDocument to a StackPanel?

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 ...

How can I add multiple FlowDocumentReaders to a StackPanel?

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 ...

How can I get a FlowDocument Hyperlink to launch browser and go to URL in a WPF app?

The following code in a WPF app creates a hyperlink that looks and acts like a hyperlink, but doesn't do anything when clicked. What do I have to change so that when I click it, it opens the default browser and goes to the specified URL? XAML: <Window x:Class="TestLink238492.Window1" xmlns="http://schemas.microsoft.com/winfx/200...

How can I produce a "print preview" of a FlowDocument in a WPF application?

Various WPF applications of mine display FlowDocument's. I'm able to print them, using the approach described in the answer to Printing a WPF FlowDocument. Now I'd like to add a "print preview" capability. In the normal case, I am printing the FlowDocument that is displayed in the Window, and so I wouldn't need a Print Preview then....