【发布时间】:2014-05-28 12:54:13
【问题描述】:
我正在使用 FlowDocumentPageViewer 控件,我想覆盖 FlowDocumentPageViewer 内部的默认缩放控件样式(+/- 按钮和滑块)。我怎样才能做到这一点?
【问题讨论】:
-
您好,欢迎来到 SO,请详细说明您的问题并提及您到目前为止尝试了什么。
我正在使用 FlowDocumentPageViewer 控件,我想覆盖 FlowDocumentPageViewer 内部的默认缩放控件样式(+/- 按钮和滑块)。我怎样才能做到这一点?
【问题讨论】:
您需要为部件 PART_FindToolBarHost 提供自定义模板。
msdn库中有完整示例:http://msdn.microsoft.com/en-us/library/aa970452(v=vs.110).aspx
【讨论】:
您需要覆盖控件的template,您不能只是简单地更改这些按钮。但是,您可以重新创建它们的行为:
XAML
<FlowDocumentPageViewer Name="myFlow">
<FlowDocumentPageViewer.Template>
<ControlTemplate>
<StackPanel>
<Button Click="ZoomIn"/>
<Button Click="ZoomOut"/>
</StackPanel>
</ControlTemplate>
</FlowDocumentPageViewer.Template>
</FlowDocumentPageViewer>
代码
private void ZoomIn(object sender, RoutedEventArgs e)
{
myFlow.IncreaseZoom();
}
private void ZoomOut(object sender, RoutedEventArgs e)
{
myFlow.DecreaseZoom();
}
【讨论】: