William Hodges
William Hodges

Reputation: 681

WinForm RichTextDocument Flow Document

So I know that there is a way do do the Flow Document in WPF. I'm looking for a way to do a FlowDocument in WinForm. Below is a snippet of code that I'm trying to get to work in WinForm and I know it works in WPF. Trying to port.

range = new TextRange(rtbPreview.Document.ContentStart, rtbPreview.Document.ContentEnd);
fstream = new FileStream(_fileName, FileMode.OpenOrCreate);
range.Load(fstream, DataFormats.XamlPackage);
fstream.Close()

It errors out on the rtbPreview.Document section. Target Framework: .NET 4.5

Upvotes: 1

Views: 1364

Answers (1)

jhmt
jhmt

Reputation: 1421

You can host a WPF control including XAML RichTextBox in your WinForms form according to this.

  1. Add System.Xaml to "Reference"
  2. Right click your project and select "Add"->"UserControl"
  3. Select "User Control (WPF)"
  4. Deploy a xaml RichTextBox on the container.
  5. Build the project.
  6. Open WinForms Form designer
  7. Click "Toolbox" view
  8. Select "{Your project name} WPF User Controls"
  9. Deploy the user control created in the step 4.

Upvotes: 1

Related Questions