UWP中的按钮菜单弹出水平对齐

时间:2015-12-17 06:31:11

标签: xaml uwp

我需要将menuflyout设置为右对齐。我使用了代码,但它只出现在左边。我需要修改风格吗?

<Button Content="Click" HorizontalAlignment="Right" Height="30" Width="30">
        <Button.Flyout>
            <MenuFlyout Placement="Bottom">
                <MenuFlyout.MenuFlyoutPresenterStyle>
                    <Style TargetType="MenuFlyoutPresenter">
                        <Setter Property="HorizontalAlignment" Value="Right" />
                        <Setter Property="MaxWidth" Value="50" />
                        <Setter Property="MaxHeight" Value="50" />
                    </Style>
                </MenuFlyout.MenuFlyoutPresenterStyle>
                <MenuFlyoutItem Text="Item" />
            </MenuFlyout>
        </Button.Flyout>
    </Button>

enter image description here

1 个答案:

答案 0 :(得分:2)

实际上,如果您使用默认设置并设置Placement MenuFlyout属性,则位置应该看起来不错。当我修改你的代码时,它应该正常工作,你需要的。 Yıu可以从截图中查看。

<Button Content="Click" HorizontalAlignment="Right" Height="30" Width="114" Margin="0,200,0,0" VerticalAlignment="Top" >
    <Button.Flyout>
        <MenuFlyout Placement="Bottom">
            <MenuFlyoutItem Text="Item" HorizontalAlignment="Right" />
        </MenuFlyout>
    </Button.Flyout>
</Button>

enter image description here

相关问题