5

A 在我的 Windows Phone 8.1 中有以下 CommandBar(我使用的是通用模板):

    <Page.BottomAppBar>
        <CommandBar>
            <AppBarButton Label="add task" Click="GoToAddTask">
                <AppBarButton.Icon>
                    <SymbolIcon Symbol="Add" />
                </AppBarButton.Icon>
            </AppBarButton>
            <AppBarButton Label="sort by">
                <AppBarButton.Icon>
                    <SymbolIcon Symbol="Sort" />
                </AppBarButton.Icon>
                <AppBarButton.Flyout>
                    <MenuFlyout>
                        <MenuFlyoutItem Command="{Binding SortByDate}" Text="Date" />
                        <MenuFlyoutItem Text="Priority" Command="{Binding SortByPriority}" />
                        <MenuFlyoutItem Text="Name" Command="{Binding SortByName}" />
                    </MenuFlyout>
                </AppBarButton.Flyout>
            </AppBarButton>
            <AppBarButton Label="pin project" Command="{Binding PinProject}">
                <AppBarButton.Icon>
                    <SymbolIcon Symbol="Pin" />
                </AppBarButton.Icon>
            </AppBarButton>
        </CommandBar>
    </Page.BottomAppBar>

问题是当用户单击AppBarButton“排序依据”时,Flyout 的底部边缘似乎卡在 AppBar 本身后面的屏幕底部。这是一个屏幕截图:

弹出定位

我检查了 Windows 8.1 的等效版本,它工作正常(例如此处所示)。

我假设 Flyout 将显示在 AppBar 本身的上方。

4

1 回答 1

7

我相信这是一个已知问题。不要将 MenuFlyout 放在行内,而是在单击事件上创建它:

private void AppBarButton_Click(object sender, RoutedEventArgs e)
        {
            MenuFlyout mf = (MenuFlyout)this.Resources["MyFlyout"];

            mf.Placement = FlyoutPlacementMode.Bottom;
            mf.ShowAt(this.root);
        }

看看这是否有效。

于 2014-05-07T16:19:46.070 回答