【问题标题】:FlowDocumentPageViewer - Styling zooming sliderFlowDocumentPageViewer - 样式缩放滑块
【发布时间】:2014-05-28 12:54:13
【问题描述】:

我正在使用 FlowDocumentPageViewer 控件,我想覆盖 FlowDocumentPageViewer 内部的默认缩放控件样式(+/- 按钮和滑块)。我怎样才能做到这一点?

【问题讨论】:

  • 您好,欢迎来到 SO,请详细说明您的问题并提及您到目前为止尝试了什么。

标签: c# wpf xaml styling


【解决方案1】:

您需要为部件 PART_FindToolBarHost 提供自定义模板。

msdn库中有完整示例:http://msdn.microsoft.com/en-us/library/aa970452(v=vs.110).aspx

【讨论】:

  • 我只是想从按钮中删除渐变,但如果没有更简单的解决方案,我会遵循这个。谢谢!
【解决方案2】:

您需要覆盖控件的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();
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-11-10
    相关资源
    最近更新 更多