Object->DispatcherObject->DependencyObject->Visual->UIElement->FrameworkElement->Control->DocumentViewerBase->FlowDocumentPageViewer
FlowDocumentPageViewer
表示一种控件,该控件以固定查看模式查看流内容(一次显示一页内容)。
FlowDocumentPageViewer 仅允许一个 FlowDocument 作为子元素。
FlowDocumentPageViewer以一次页面查看模式显示内容。类似的控件FlowDocumentScrollViewer,以连续滚动模式显示内容。既FlowDocumentPageViewer和FlowDocumentScrollViewer被固定到特定的观看模式。另一方面,FlowDocumentReader包含使用户能够在各种查看模式之间动态选择的功能(由FlowDocumentReaderViewingMode枚举提供),但其性能比FlowDocumentPageViewer或FlowDocumentScrollViewer差。
下图显示了带有默认用户界面(UI)的FlowDocumentPageViewer控件。
-
Content Area -Content Area显示Document 属性指定FlowDocument 的内容 。
-
Toolbar -默认工具栏停靠在内容区域的下方,并承载用于导航页面和更改缩放级别的控件。
名称 | 备注 | 权限 |
---|---|---|
CanDecreaseZoomProperty | 标识 CanDecreaseZoom 依赖项属性。 | public static readonly |
CanDecreaseZoomPropertyKey | 标识 CanDecreaseZoom 依赖项属性。 | public static readonly |
CanIncreaseZoomProperty | 标识 CanIncreaseZoom 依赖项属性。 | public static readonly |
CanIncreaseZoomPropertyKey | 标识 CanIncreaseZoom 依赖项属性。 | public static readonly |
IsInactiveSelectionHighlightEnabledProperty | 标识 IsInactiveSelectionHighlightEnabled 依赖项属性。 | public static readonly |
IsSelectionActiveProperty | 标识 IsSelectionActive 依赖项属性。 | public static readonly |
MaxZoomProperty | 标识 MaxZoom 依赖项属性。 | public static readonly |
MinZoomProperty | 标识 MinZoom 依赖项属性。 | public static readonly |
SelectionBrushProperty | 标识 SelectionBrush 依赖项属性。 | public static readonly |
SelectionOpacityProperty | 标识 SelectionOpacity 依赖项属性。 | public static readonly |
ZoomIncrementProperty | 标识 ZoomIncrement 依赖项属性。 | public static readonly |
ZoomProperty | 标识 Zoom 依赖项属性。 | public static readonly |
名称 | 备注 | 权限 |
---|---|---|
CanDecreaseZoom | 获取一个值,该值指示是否可以降低 Zoom 级别。 | get; |
CanIncreaseZoom | 获取一个值,该值指示是否可以增加 Zoom 级别。 | get; |
IsInactiveSelectionHighlightEnabled | 获取或设置指示 FlowDocumentPageViewer 是否在控件没有焦点时显示所选文本的值。 | get; set; |
IsSelectionActive | 获取指示 FlowDocumentPageViewer 是否具有焦点和选择文本的值。 | get; |
MaxZoom | 获取或设置 Zoom 允许的最大 FlowDocumentPageViewer 级别。 | get; set; |
MinZoom | 获取或设置 Zoom 允许的最小 FlowDocumentPageViewer 级别。 | get; set; |
Selection | 获取 FlowDocumentPageViewer 的所选内容。 | get; |
SelectionBrush | 获取或设置用于突出显示选定文本的画笔。 | get; set; |
SelectionOpacity | 获取或设置 SelectionBrush 的不透明度。 | get; set; |
Zoom | 获取或设置 FlowDocumentPageViewer 的当前缩放级别。 | get; set; |
ZoomIncrement | 获取或设置缩放增量。 | get; set; |
名称 | 备注 | 权限 |
---|---|---|
DecreaseZoom | 执行 DecreaseZoom 路由命令。 | public |
Find | 切换“查找”对话框。 | public |
IncreaseZoom | 执行 IncreaseZoom 路由命令。 | public |
OnApplyTemplate | 为 FlowDocumentPageViewer 构建可视化树。 | public |
OnCancelPrintCommand | 处理 CancelPrint 路由命令。 | protected |
OnContextMenuOpening | 只要未处理的 ContextMenuOpening 路由事件在其路由中到达此类,就会调用此方法。 实现此方法可为此事件添加类处理。 | protected |
OnCreateAutomationPeer | 提供 AutomationPeer 此控件的适当实现,作为 WPF 自动化基础结构的一部分。 | protected |
OnDecreaseZoomCommand | 处理 DecreaseZoom 路由命令。 | protected |
OnDocumentChanged | 当 Document 属性更改时调用。 | protected |
OnFindCommand | 处理 Find 路由命令。 | protected |
OnFirstPageCommand | 处理 FirstPage 路由命令。 | protected |
OnGoToPageCommand | 处理 GoToPage 路由命令。 | protected |
OnIncreaseZoomCommand | 处理 IncreaseZoom 路由命令。 | protected |
OnKeyDown | 处理 KeyDown 路由事件。 | protected |
OnLastPageCommand | 处理 LastPage 路由命令。 | protected |
OnMouseWheel | 处理 MouseWheel 路由事件。 | protected |
OnNextPageCommand | 处理 NextPage 路由命令。 | protected |
OnPageViewsChanged | 处理 PageViewsChanged 路由事件。 | protected |
OnPreviousPageCommand | 处理 PreviousPage 路由命令。 | protected |
OnPrintCommand | 处理 Print 路由命令。 | protected |
OnPrintCompleted | 完成一个打印作业后调用。 | protected |
简单范例
<Window x:Class="FlowDocumentPageViewerDemo.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:FlowDocumentPageViewerDemo"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<FlowDocumentPageViewer>
<FlowDocument Background="LightGreen" FlowDirection="LeftToRight" >
<Paragraph>
<Bold>
FlowDocumentReader是提供一种查看流内容的控件,该控件内置了对多种查看模式的支持。
</Bold>
</Paragraph>
<Paragraph>
<Bold>
FlowDocumentReader具有使用户能够在各种查看模式之间动态选择的功能,包括单页(一次页面)查看模式,一次两页(书本阅读格式)查看模式,以及连续滚动(无底)观看模式。如果您不需要在不同的查看模式之间动态切换的功能,可以使用固定在特定查看模式下的轻量级流内容查看器。 FlowDocumentPageViewer以单页查看模式显示流内容,而FlowDocumentScrollViewer以连续滚动模式显示流内容。有关可用显示模式的更多信息,请参见FlowDocumentReaderViewingMode。
</Bold>
<Bold>
Content Area -Content Area显示 FlowDocument Document 属性指定的的内容。
Tool Bar 工具栏停靠在Content Area的下方。 它承载用于搜索内容、导航页面、选择查看模式和更改缩放级别的控件。
Find Button “查找”按钮显示 "查找" 对话框,该对话框允许用户在 FlowDocumentReader 的内容中搜索指定的词或短语。 如果 IsFindEnabled 为false ,则不显示 " 查找 " 按钮。 有关详细信息,请参阅 Find。
Page Navigation Controls -页面导航控件包含一个按钮,用于跳转到下一页 (向下箭头) 或上一页 ("向上" 箭头) ,以及当前页码和总页数的指示器。
Viewing Mode Buttons -使用查看模式按钮,用户可以从可用的查看模式中进行选择。 有关详细信息,请参阅 ViewingMode。
Zoom Controls -通过单击加号或减号按钮,用户可以使用缩放控件来增加或减少缩放级别。 缩放控件还包括一个用于调整缩放级别的滑块。 有关详细信息,请参阅 Zoom。
</Bold>
</Paragraph>
<Paragraph>
<Bold>
FlowDocumentReader具有使用户能够在各种查看模式之间动态选择的功能,包括单页(一次页面)查看模式,一次两页(书本阅读格式)查看模式,以及连续滚动(无底)观看模式。如果您不需要在不同的查看模式之间动态切换的功能,可以使用固定在特定查看模式下的轻量级流内容查看器。 FlowDocumentPageViewer以单页查看模式显示流内容,而FlowDocumentScrollViewer以连续滚动模式显示流内容。有关可用显示模式的更多信息,请参见FlowDocumentReaderViewingMode。
</Bold>
</Paragraph>
<Paragraph>
<Bold>
Content Area -Content Area显示 FlowDocument Document 属性指定的的内容。
Tool Bar 工具栏停靠在Content Area的下方。 它承载用于搜索内容、导航页面、选择查看模式和更改缩放级别的控件。
Find Button “查找”按钮显示 "查找" 对话框,该对话框允许用户在 FlowDocumentReader 的内容中搜索指定的词或短语。 如果 IsFindEnabled 为false ,则不显示 " 查找 " 按钮。 有关详细信息,请参阅 Find。
Page Navigation Controls -页面导航控件包含一个按钮,用于跳转到下一页 (向下箭头) 或上一页 ("向上" 箭头) ,以及当前页码和总页数的指示器。
Viewing Mode Buttons -使用查看模式按钮,用户可以从可用的查看模式中进行选择。 有关详细信息,请参阅 ViewingMode。
Zoom Controls -通过单击加号或减号按钮,用户可以使用缩放控件来增加或减少缩放级别。 缩放控件还包括一个用于调整缩放级别的滑块。 有关详细信息,请参阅 Zoom。
</Bold>
</Paragraph>
</FlowDocument>
</FlowDocumentPageViewer>
</Window>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace FlowDocumentScrollViewerDemo
{
/// <summary>
/// MainWindow.xaml 的交互逻辑
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
}
}