将FlowDocument添加到主窗口
本文关键字:窗口 添加 FlowDocument | 更新日期: 2023-09-27 18:26:50
将保存为Xaml的FlowDocument添加到应用程序主窗口的最佳做法是什么。
<Window x:Class="Test.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<FlowDocumentReader Document="">
<FlowDocument>
<!-- I WANT TO ADD THE FLOWDOCUMENT I SAVED AS AN XAML HERE-->
</FlowDocument>
</FlowDocumentReader>
</Grid>
</Window>
谢谢。
我在这个页面上使用了这个例子。
http://msdn.microsoft.com/en-us/library/ms751864(v=vs.85).aspx
Xaml代码
<Window x:Class="Test.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="20"></RowDefinition>
<RowDefinition Height="100*"></RowDefinition>
</Grid.RowDefinitions>
<Button Name="PrintSimpleTextButton" Content="Print Button" Width="100" Grid.Row="0" Click="PrintSimpleTextButton_Click"></Button>
<FlowDocumentReader
Name="flowDocRdr"
IsFindEnabled="True"
IsPrintEnabled="True"
MinZoom="50" MaxZoom="1000"
Zoom="100" ZoomIncrement="5"
Grid.Row="1"
/>
</Grid>
</Window>
加载流程文档的代码
private void PrintSimpleTextButton_Click(object sender, RoutedEventArgs e)
{
string filename = "C:''Users''Me''Dropbox''Engineering''Practice''C# Xaml''PrinterTest''PrinterTest''QRCodeStyleA_FlowDoc.xaml";
FileStream xamlFile = new FileStream(filename, FileMode.Open, FileAccess.Read);
FlowDocument content = System.Windows.Markup.XamlReader.Load(xamlFile) as FlowDocument;
flowDocRdr.Document = content;
}