【问题标题】:Decrease the size of the Menu Flyout in windows Universal App for Mobile?减小 Windows Universal App for Mobile 中菜单弹出的大小?
【发布时间】:2016-06-13 07:33:48
【问题描述】:

我正在 Mobile 中使用 windows 通用应用程序(Windows 10)。我在菜单弹出中进行了查询。菜单弹出的默认宽度保持不变,在此代码之后不会减少:

<AppBarButton Icon="OpenWith" Label="More.." Width="55">
                    <AppBarButton.Flyout>
                        <MenuFlyout>
                            <MenuFlyout.MenuFlyoutPresenterStyle>
                                <Style TargetType="MenuFlyoutPresenter">
                                    <Setter Property="Margin" Value="0,-31,0,0" />
                                    <Setter Property="Background" Value="#FFE45427" />
                                    <Setter Property="FontSize" Value="12" />
                                    <Setter Property="BorderBrush" Value="Transparent" />
                                    <Setter Property="MinWidth" Value="70" />
                                </Style>
                            </MenuFlyout.MenuFlyoutPresenterStyle>
                            <MenuFlyoutItem Text="Logout" FontSize="13" Padding="8,8,0,8"   Click="MenuFlyoutItem_Click" />
                            <MenuFlyoutItem Text="Sales" FontSize="13" Padding="8,8,0,8"  Click="appbarsales_Click" />
                        </MenuFlyout>
                    </AppBarButton.Flyout>
                </AppBarButton>

图片:

【问题讨论】:

  • 你试过this吗?
  • @AlexejSommer:是的。我也尝试过这个东西,但我只想减少菜单弹出宽度。我可以轻松增加宽度,但我不知道如何减少宽度,所以如果你知道,请提出更好的方法。

标签: wpf xaml win-universal-app windows-10


【解决方案1】:
 <Page.BottomAppBar>
        <AppBar x:Name="applicationbar">
         <AppBarButton Icon="OpenWith" Label="More.."  x:Name="more_item">
                    <AppBarButton.Flyout>
                        <MenuFlyout>
                            <MenuFlyout.MenuFlyoutPresenterStyle>
                                <Style TargetType="MenuFlyoutPresenter">
                                    <Setter Property="Margin" Value="0,-31,0,0" />
                                    <Setter Property="Background" Value="#FFE45427" />
                                    <Setter Property="FontSize" Value="12" />
                                    <Setter Property="BorderBrush" Value="Transparent" />
                                    <Setter Property="MaxWidth" Value="70"/>

                                </Style>
                            </MenuFlyout.MenuFlyoutPresenterStyle>
                            <MenuFlyoutItem Text="Logout" FontSize="13" Padding="8,8,0,8"   Click="MenuFlyoutItem_Click" >

                            </MenuFlyoutItem>
                            <MenuFlyoutItem Text="Sales" FontSize="13" Padding="8,8,0,8"  Click="appbarsales_Click" />
                        </MenuFlyout>
                    </AppBarButton.Flyout>
                </AppBarButton>
            </StackPanel>

        </AppBar>

使用 MaxWidth 属性来减小 Menu Flyout 的默认大小

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-28
    • 1970-01-01
    • 2019-02-28
    • 2012-10-19
    • 2016-09-22
    相关资源
    最近更新 更多