2,856 questions
Hi, in .NET Core 3.1. it work fine:
<Window x:Class="WpfApp1.Window02"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfApp02"
mc:Ignorable="d"
Title="Window02" Height="450" Width="800">
<Window.DataContext>
<local:ViewModel/>
</Window.DataContext>
<Grid>
<DocumentViewer Document="{Binding Doc}"/>
</Grid>
</Window>
-----------------------------------------------
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
namespace WpfApp02
{
public class ViewModel
{
public ViewModel()
{
Doc = RenderDocument();
}
public IDocumentPaginatorSource Doc { get; set; }
public FixedDocument RenderDocument()
{
FixedDocument fd = new FixedDocument();
PageContent pc = new PageContent();
FixedPage fp = new FixedPage();
TextBlock tb = new TextBlock();
// add some text to a TextBox object
tb.Text = "This is some test text";
// add the text box to the FixedPage
fp.Children.Add(tb);
// ,add the FixedPage to the PageContent
pc.Child = fp;
// add the PageContent to the FixedDocument
fd.Pages.Add(pc);
return fd;
}
}
}