首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >向MainWindow添加FlowDocument

向MainWindow添加FlowDocument
EN

Stack Overflow用户
提问于 2013-08-09 00:31:48
回答 1查看 969关注 0票数 2

将保存为Xaml的FlowDocument添加到应用程序的主窗口的最佳实践是什么。

代码语言:javascript
复制
<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>

谢谢。

EN

回答 1

Stack Overflow用户

发布于 2013-08-09 01:28:34

我使用了这个页面上的示例。

http://msdn.microsoft.com/en-us/library/ms751864(v=vs.85).aspx

Xaml代码

代码语言:javascript
复制
<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>

用于加载流文档的代码

代码语言:javascript
复制
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;


        }
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18131299

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档