wpf-devexpress-dot-xpf-dot-documentviewer-dot-documentviewercontrol-ecd23007.md
Using file paths sourced from untrusted input may expose unauthorized files or allow unintended file access. Always validate and normalize all external paths to prevent path manipulation.
Specifies the document source. This is a dependency property.
Namespace : DevExpress.Xpf.DocumentViewer
Assembly : DevExpress.Xpf.DocumentViewer.v25.2.Core.dll
NuGet Package : DevExpress.Wpf.DocumentViewer.Core
public object DocumentSource { get; set; }
Public Property DocumentSource As Object
| Type | Description |
|---|---|
| Object |
A Object value that specifies the document source.
|
The following source types are supported:
You can use the DocumentSource property to load a previously saved document from the PRNX file:
documentPreview.DocumentSource = @"...\Invoice.prnx";
To create a custom DocumentPreviewWindow, assign a document source to the DocumentSource property (available when using the DocumentPreviewWindow.PreviewControl property).
using DevExpress.Xpf.Printing;
using System.Windows;
// ...
private void Button_Click(object sender, RoutedEventArgs e) {
XtraReport1 report = new XtraReport1();
var window = new DocumentPreviewWindow();
window.PreviewControl.DocumentSource = report;
report.CreateDocument();
window.Show();
}
Imports DevExpress.Xpf.Printing
Imports System.Windows
' ...
Private Sub Button_Click(sender As Object, e As RoutedEventArgs)
Dim report As New XtraReport1()
Dim window = New DocumentPreviewWindow()
window.PreviewControl.DocumentSource = report
report.CreateDocument()
window.Show()
End Sub
Make sure to call the XtraReport.CreateDocument method before displaying the Print Preview.
To resolve subreport names, call ReportStorageExtension.RegisterExtensionGlobal.
The following code snippets (auto-collected from DevExpress Examples) contain references to the DocumentSource property.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.
reporting-wpf-mvvm-show-report-document-preview/CS/MainWindow.xaml#L17
<dxp:DocumentPreviewControl RequestDocumentCreation="True"
DocumentSource="{Binding Report}" />
</DataTemplate>
wpf-reporting-use-custom-controls-for-editing-report-content-in-print-preview/CS/MainWindow.xaml#L26
<DataTemplate>
<dxp:DocumentPreviewControl RequestDocumentCreation="True" DocumentSource="{Binding Report, Mode=OneWay}" />
</DataTemplate>
wpf-pdf-viewer-replace-standard-command-with-custom-command/CS/MainWindow.xaml#L19
<pdfViewer:PdfViewerControl x:Name="pdfViewer" DocumentSource="Demo.pdf">
reporting-wpf-mvvm-how-to-validate-editing-fields/CS/MainWindow.xaml#L13
<dxp:DocumentPreviewControl RequestDocumentCreation="True"
DocumentSource="{Binding Report}"
HighlightEditingFields="True">
reporting-wpf-mvvm-viewmodel-data-to-report/CS/MainWindow.xaml#L19
<dxp:DocumentPreviewControl RequestDocumentCreation="True"
DocumentSource="{Binding Report}" />
</DataTemplate>
preview.DocumentSource = link;
link.CreateDocument();
reporting-wpf-print-listview-data/CS/Window1.xaml.cs#L18
DocumentPreviewWindow preview = new DocumentPreviewWindow();
preview.PreviewControl.DocumentSource = link;
wpf-pdf-viewer-draw-a-rectangle-over-a-document/CS/MainWindow.xaml.cs#L25
InitializeComponent();
pdfView.DocumentSource = "Demo.pdf";
}
reporting-wpf-print-listview-data/VB/Window1.xaml.vb#L21
Dim preview As DocumentPreviewWindow = New DocumentPreviewWindow()
preview.PreviewControl.DocumentSource = link
link.PageHeaderTemplate = CType(Resources("printHeaderTemplate"), DataTemplate)
wpf-pdf-viewer-draw-a-rectangle-over-a-document/VB/MainWindow.xaml.vb#L16
Me.InitializeComponent()
Me.pdfView.DocumentSource = "Demo.pdf"
End Sub
See Also