【问题标题】:Splitview Pane & Page CommandBar & Keyboard overlaps each other拆分视图窗格和页面命令栏和键盘相互重叠
【发布时间】:2016-09-12 15:01:11
【问题描述】:

当我使用SplitView 和CommandBar 时,我将CommandBar 放在Page.BottomAppBar 中,但是CommandBar 与SplitView Pane 重叠。所以我将 CommandBar 移动到页面的内容(如:Page command bar overlaps Splitview Pane)。它正在工作。

但这需要一个新问题。在显示键盘的页面中时,键盘与 CommandBar 重叠。我想在键盘显示时显示 CommandBar。我该怎么做?

【问题讨论】:

标签: uwp commandbar splitview


【解决方案1】:

我可以在这里给一个workground,也许有点笨拙,但它可以解决你的问题。

由于Page.BottomAppBar中的CommandBar在软件键盘可见时不会被隐藏,但它与SplitView Pane重叠,我们可以保留Grid的内容中的CommandBar,但复制这个@987654324 @并将其放入Page.BottomAppBar中,同时先使其折叠,例如这样:

<Page.BottomAppBar>
    <CommandBar x:Name="AppCommandBarCopy" Visibility="Collapsed">
        <CommandBar.PrimaryCommands>
            <AppBarButton Name="SaveCopy"
                          Icon="Save"
                          Label="Save"></AppBarButton>
            <AppBarButton Name="ClearCopy"
                          Icon="ClearSelection"
                          Label="Clear"></AppBarButton>
        </CommandBar.PrimaryCommands>
    </CommandBar>
</Page.BottomAppBar>

然后在后面的代码中,我们可以检测软键盘是否可见,如果键盘可见,则显示这个副本;如果没有,请隐藏此副本,例如这里:

public SplitViewCommandBarKeyboard()
{
    this.InitializeComponent();
    InputPane.GetForCurrentView().Showing += OnKeyboardShowing;
    InputPane.GetForCurrentView().Hiding += OnKeyboardHidding;
}

private void OnKeyboardHidding(InputPane sender, InputPaneVisibilityEventArgs args)
{
    AppCommandBarCopy.Visibility = Visibility.Collapsed;
}

private void OnKeyboardShowing(InputPane sender, InputPaneVisibilityEventArgs args)
{
    AppCommandBarCopy.Visibility = Visibility.Visible;
}

【讨论】:

  • @LabanLiaoL,不客气!因此,如果这是一个可以接受的答案,您能否将其标记为答案?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-03-04
  • 1970-01-01
  • 2017-10-17
  • 2019-03-25
  • 1970-01-01
相关资源
最近更新 更多