如何在MenuFlyout中禁用ZoomOut效果

时间:2015-08-17 10:03:26

标签: xaml windows-runtime windows-phone-8.1 winrt-xaml

在silverlight中,上下文菜单曾经有一个属性IsZoomEnabled,用于定义ContextMenu出现时缩小效果是否存在但在winrt xaml中我们有MenuFlyout没有任何这样的财产。我应该如何禁用此效果?

这是MenuFlyout的默认模板

<!-- Default style for Windows.UI.Xaml.Controls.MenuFlyoutPresenter -->
<Style TargetType="MenuFlyoutPresenter">
    <Setter Property="RequestedTheme" Value="Light" />
    <Setter Property="Background" Value="{ThemeResource FlyoutBackgroundThemeBrush}" />
    <Setter Property="BorderBrush" Value="{ThemeResource FlyoutBorderThemeBrush}" />
    <Setter Property="BorderThickness" Value="{ThemeResource FlyoutBorderThemeThickness}" />
    <Setter Property="Padding" Value="{ThemeResource MenuFlyoutPresenterThemePadding}" />
    <Setter Property="ScrollViewer.HorizontalScrollMode" Value="Disabled" />
    <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled" />
    <Setter Property="ScrollViewer.VerticalScrollMode" Value="Auto" />
    <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" />
    <Setter Property="ScrollViewer.IsHorizontalRailEnabled" Value="False" />
    <Setter Property="ScrollViewer.IsVerticalRailEnabled" Value="False" />
    <Setter Property="ScrollViewer.ZoomMode" Value="Disabled" />
    <Setter Property="MinWidth" Value="{ThemeResource FlyoutThemeMinWidth}" />
    <Setter Property="MaxWidth" Value="{ThemeResource FlyoutThemeMaxWidth}" />
    <Setter Property="MinHeight" Value="{ThemeResource FlyoutThemeMinHeight}" />
    <Setter Property="MaxHeight" Value="{ThemeResource FlyoutThemeMaxHeight}" />
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="MenuFlyoutPresenter">
                <Border Background="{TemplateBinding Background}"
                        BorderBrush="{TemplateBinding BorderBrush}"
                        BorderThickness="{TemplateBinding BorderThickness}">
                    <ScrollViewer Padding="{TemplateBinding Padding}"
                                  HorizontalScrollMode="{TemplateBinding ScrollViewer.HorizontalScrollMode}"
                                  HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}"
                                  VerticalScrollMode="{TemplateBinding ScrollViewer.VerticalScrollMode}"
                                  VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}"
                                  IsHorizontalRailEnabled="{TemplateBinding ScrollViewer.IsHorizontalRailEnabled}"
                                  IsVerticalRailEnabled="{TemplateBinding ScrollViewer.IsVerticalRailEnabled}"
                                  ZoomMode="{TemplateBinding ScrollViewer.ZoomMode}"
                                  AutomationProperties.AccessibilityView="Raw">
                        <ItemsPresenter />
                    </ScrollViewer>
                </Border>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

1 个答案:

答案 0 :(得分:0)

你无法在WinRT中完成此任务。您可以仅使用UserControl创建自己的MenuFlyout或复制Flyout的行为。如果你想做这样的事情,请尝试this教程。