我试图让打印预览工作,但我似乎无法显示任何内容。 我有一个名为ScreenShotForm的表单,它使用DocumentViewer。这是xaml代码:
<Window
x:Class="S3DDesktop.Apps.SchematicDesigner.Dialogs.ScreenShotForm"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="{Binding SchematicDesignerAppStrings.Header_Preview, Source={StaticResource LocalizedStrings}}">
<DocumentViewer
Name="_viewer" >
<DocumentViewer.Resources>
<Style TargetType="ContentControl">
<Style.Triggers>
<Trigger Property="Name" Value="PART_FindToolBarHost">
<Setter Property="Visibility" Value="Collapsed"/>
</Trigger>
</Style.Triggers>
</Style>
</DocumentViewer.Resources>
</DocumentViewer>
它背后的代码只返回一个Document属性:
public IDocumentPaginatorSource Document
{
get { return _viewer.Document; }
set { _viewer.Document = value; }
}
然后我有我的视图模型,我在ScreenShotForm上调用,以使打印预览工作。这就是我坚持的地方。窗口弹出正常,但它不显示任何内容。
ScreenShotForm oForm = new ScreenShotForm();
oForm.DataContext = this;
oForm.ShowDialog();
我知道我错过了什么,但我无法弄清楚。 :