标签: flowdocumentscrollviewer

如何在WPF应用程序中生成FlowDocument的"打印预览"?

我的各种WPF应用程序显示FlowDocument的.我可以使用打印WPF FlowDocument 的答案中描述的方法打印它们.

现在我想添加一个"打印预览"功能.在正常情况下,我正在打印窗口中显示的FlowDocument,因此我不需要打印预览.但在某些情况下,要打印的FlowDocument是在内存中即时构建的.在这些情况下,我想在打印前显示它.

现在,我当然可以弹出一个新窗口并显示FlowDocument,但是

  1. 我希望预览真的感觉它是打印操作的一部分,而不仅仅是应用程序中的另一个窗口.

  2. 我不想在FlowDocumentScrollViewer中使用普通的FlowDocument.它不是"任何大小",而是需要约束纸张的大小,特定的HxW比率和分页.

建议?

  • 我应该只使用标准窗口,在这种情况下,如何确保FlowDocument处于适当的比例?

  • 是否有更"集成"的方式在Windows的PrintDialog UI范围内进行预览?

谢谢

.net printing wpf flowdocument flowdocumentscrollviewer

15
推荐指数
1
解决办法
3万
查看次数

为什么我不能粘贴从WPF FlowDocumentScrollViewer或Reader复制的文本?

在上一个问题中,我试图找出如何将ObservableCollection绑定到控件,这样我就可以看到所有字符串并选择所有字符串并从内容控件中复制它们.这个问题的答案最终通过使用以下XAML得到了我想要的外观(看似行为).(我尝试了FlowDocumentReader和FlowDocumentScrollViewer - 它们的行为相同.)

<Grid>
<FlowDocumentScrollViewer>
    <FlowDocument >
        <Paragraph>
            <ItemsControl ItemsSource="{Binding ErrorMessages, Mode=OneWay}" />
            <Run Text="{Binding /, Mode=OneWay}" />
        </Paragraph>
    </FlowDocument>
</FlowDocumentScrollViewer>
</Grid>
Run Code Online (Sandbox Code Playgroud)

ErrorMessages是我的ViewModel属性,它返回一个ObservableCollection <string>.它正确绑定到ItemsSource,<Run>元素绑定到集合中的每个字符串.看起来不错,持续很长时间.这是如此接近我标记我的最后一个问题,但我仍有一个问题.

我右键单击,菜单显示" 选择所有"和" 复制"选项.使用全,确实突出显示所有文本,选择复制问题没有错误,但当我转到NotePad(或Word,或TextPad等或表格上的RTB)并尝试粘贴文本时,没有任何显示.作为WPF的新手,我怀疑我做错了什么,但我不知道它是什么.那里没有"看不见"的文字吗?

[编辑 - 2011年6月22日]由于其他原因,我已经通过ItemsControl中的ItemTemplate更改了代码以使用TextBlock,如下所示,但我仍然无法复制和粘贴.

<DataTemplate x:Key="StringCollection">
   <TextBlock TextWrapping="Wrap" Text="{Binding}" TextAlignment="Left"/>
</DataTemplate>
<!--... now down in the ItemsControl-->
<ItemsControl ItemsSource="{Binding ReceivedData, Mode=OneWay}"
      ItemTemplate="{StaticResource StringCollection}" />
Run Code Online (Sandbox Code Playgroud)

wpf copy-paste flowdocument flowdocumentscrollviewer flowdocumentreader

6
推荐指数
1
解决办法
1294
查看次数

FlowDocumentScrollViewer中的Horizo​​natal滚动

我有一个带有图像的流文档(从图纸中创建).我已经为用户提供了一个按钮,可以独立放大图像(缩放)而无需缩放文本.

无论如何,我可以强制FlowDocumentScrollViewer显示水平滚动条,以便在放大图像时滚动?目前,放大的图像被简单地剪掉.

最好的问候,
保罗.

wpf flowdocumentscrollviewer

3
推荐指数
1
解决办法
1068
查看次数

使用字符串创建流文档

我有一些正在从数据库中读取的文本.此文本是xaml节对象的字符串表示形式.此文本将根据组合框中的选择而有所不同.以下是一些文字示例:

<Section xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xml:space="preserve" TextAlignment="Left" LineHeight="Auto" IsHyphenationEnabled="False" xml:lang="en-us" FlowDirection="LeftToRight" NumberSubstitution.CultureSource="User" NumberSubstitution.Substitution="AsCulture" FontFamily="Verdana" FontStyle="Normal" FontWeight="Normal" FontStretch="Normal" FontSize="11" Foreground="#FF000000" Typography.StandardLigatures="True" Typography.ContextualLigatures="True" Typography.DiscretionaryLigatures="False" Typography.HistoricalLigatures="False" Typography.AnnotationAlternates="0" Typography.ContextualAlternates="True" Typography.HistoricalForms="False" Typography.Kerning="True" Typography.CapitalSpacing="False" Typography.CaseSensitiveForms="False" Typography.StylisticSet1="False" Typography.StylisticSet2="False" Typography.StylisticSet3="False" Typography.StylisticSet4="False" Typography.StylisticSet5="False" Typography.StylisticSet6="False" Typography.StylisticSet7="False" Typography.StylisticSet8="False" Typography.StylisticSet9="False" Typography.StylisticSet10="False" Typography.StylisticSet11="False" Typography.StylisticSet12="False" Typography.StylisticSet13="False" Typography.StylisticSet14="False" Typography.StylisticSet15="False" Typography.StylisticSet16="False" Typography.StylisticSet17="False" Typography.StylisticSet18="False" Typography.StylisticSet19="False" Typography.StylisticSet20="False" Typography.Fraction="Normal" Typography.SlashedZero="False" Typography.MathematicalGreek="False" Typography.EastAsianExpertForms="False" Typography.Variants="Normal" Typography.Capitals="Normal" Typography.NumeralStyle="Normal" Typography.NumeralAlignment="Normal" Typography.EastAsianWidths="Normal" Typography.EastAsianLanguage="Normal" Typography.StandardSwashes="0" Typography.ContextualSwashes="0" Typography.StylisticAlternates="0"><Paragraph><Run>Hello World      </Run></Paragraph></Section>
Run Code Online (Sandbox Code Playgroud)

我需要采取此文本并在应用程序的控件中正确格式化显示它.我相信,为了做到这一点,我需要一个FlowDocumentViewer(我正在使用FlowDocumentScrollViewer).

我无法弄清楚的是如何将文本转换为流文档,以便我可以将它(绑定它)与文档查看器关联(我在此处是一个菜鸟).

有人可以帮忙吗?

c# wpf xaml flowdocument flowdocumentscrollviewer

1
推荐指数
1
解决办法
4745
查看次数