我的 UWP 应用程序中有一个命令栏,我想隐藏该栏并仅在用户单击隐藏按钮时显示省略号按钮。另外,我希望在启动应用程序时打开/显示命令栏。
这是我的命令栏的样子,
当我点击最后一个按钮时,我试图得到这样的东西:
这是我给设计师的代码:
<CommandBar IsSticky="True"
Name="WebViewCommandBar"
Height="52"
Background="{StaticResource CitiKioskBackgroundBrush}"
HorizontalAlignment="Stretch"
VerticalAlignment="Bottom"
OverflowButtonVisibility="Collapsed">
<CommandBar.Transitions>
<TransitionCollection>
</TransitionCollection>
</CommandBar.Transitions>
<CommandBar.PrimaryCommands>
<AppBarButton Icon="Back"
IsCompact="True"
IsEnabled="{Binding CanGoBack,ElementName=webView}"
Name="WebViewBackButton"
Click="WebViewBackButton_Click" />
<AppBarButton Icon="Forward"
IsCompact="True"
IsEnabled="{Binding CanGoForward,ElementName=webView}"
Name="WebViewForwardButton"
Click="WebViewForwardButton_Click"
Margin="0 0 1450 0"/>
<AppBarButton
IsCompact="True"
Name="WebViewContactButton"
Click="WebViewContactButton_Click"
Foreground="White">
<AppBarButton.Icon>
<BitmapIcon UriSource="ms-appx:///Assets/Images/icon_smsLocation.png"/>
</AppBarButton.Icon>
</AppBarButton>
<AppBarButton Icon="Refresh"
IsCompact="True"
Name="WebViewRefreshButton"
Click="WebViewRefreshButton_Click"
Foreground="White"/>
<AppBarButton Icon="DockBottom"
IsCompact="True"
Name="WebViewHideNavigationButton"
Click="WebViewHideNavigationButton_Click"
Foreground="White"/>
</CommandBar.PrimaryCommands>
</CommandBar>
对于我的按钮单击事件:
private void WebViewHideNavigationButton_Click(object sender, RoutedEventArgs e)
{
WebViewCommandBar.IsOpen = false;
}