<Window x:Class="WpfApplication1.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="600" Width="800">
<TabControl>
<TabItem Header="Fixed Document">
<DockPanel>
<Button DockPanel.Dock="Bottom" Content="Open..." Click="btnOpenFlowDoc_Click"/>
<DocumentViewer x:Name="dvDocumentViewer" />
</DockPanel>
</TabItem>
</TabControl>
</Window>
//File:Window.xaml.vb
Imports System
Imports System.IO
Imports System.Windows
Imports System.Windows.Documents
Imports System.Windows.Markup
Imports System.Windows.Xps.Packaging
Imports System.Xml
Imports Microsoft.Win32
Namespace WpfApplication1
Public Partial Class Window1
Inherits Window
Public Sub New()
InitializeComponent()
End Sub
Private Sub btnOpenFlowDoc_Click(sender As Object, e As RoutedEventArgs)
Dim file__1 As Stream = InlineAssignHelper(file__1, File.OpenRead("c:\b.xps"))
Dim reader As TextReader = New StreamReader(file__1)
Dim xmlReader As New XmlTextReader(reader)
Dim flowDocument As FlowDocument = TryCast(XamlReader.Load(xmlReader), FlowDocument)
dvDocumentViewer.Document = flowDocument
End Sub
Private Shared Function InlineAssignHelper(Of T)(ByRef target As T, value As T) As T
target = value
Return value
End Function
End Class
End Namespace
|