问题描述
限时送ChatGPT账号..如何向 Windows Phone 8.1 应用程序中的 Hub 元素添加不同的 CommandBars (AppBars).我想为每个 Hub Section 使用不同的 CommandBar,但我无法在 Hub Section 中声明 CommandBar.所以我只能在 Hub 中使用一个 CommandBar.
How can I add different CommandBars (AppBars) to an Hub element in Windows Phone 8.1 app. I want to have a different CommandBar for each Hub Section, but I can't declare the CommandBar in the Hub Section. So I can only use one CommandBar in the Hub.
推荐答案
您可以创建 4 个以上的 AppBarButton 并使其不可见,然后更改每个 Hub 部分的可见性属性.菜单按钮的方式相同.
You can create more than 4 AppBarButton and make it invisible then you change Visibility Property for each per Hub Section. Same way for menu button.
示例:
<Page.BottomAppBar>
<CommandBar>
<CommandBar.PrimaryCommands>
<AppBarButton x:Uid="Quick" Name="QuickAppBarButton" Label="quick" Icon="Pin" Click="AppBarButton_Click"/>
<AppBarButton x:Uid="Quick" Name="AddAppBarButton" Label="add" Icon="Add" Click="AppBarButton_Click"/>
<AppBarButton x:Uid="Quick"
Name="CalcAppBarButton"
Label="calculator"
Icon="Calculator"
Click="AppBarButton_Click" />
</CommandBar.PrimaryCommands>
<CommandBar.SecondaryCommands>
<AppBarButton x:Uid="Accounts" Name="AccountsSecondaryButton" Label="accounts" Click="AccountsSecondaryButton_Click"/>
<AppBarButton x:Uid="CurrencyMenu" Name="CurrencySecondaryButton" Label="currency" Click="CurrencySecondaryButton_Click"/>
<AppBarButton x:Uid="Categories" Label="categories"/>
<AppBarButton x:Uid="Settings" Label="settings" Name="SettingsSecondaryButton" Click="SettingsSecondaryButton_Click"/>
<AppBarButton x:Uid="Tutorials" Label="tutorials"/>
<AppBarButton x:Uid="About" Label="about"/>
</CommandBar.SecondaryCommands>
</CommandBar>
</Page.BottomAppBar>
和 C# 文件(您必须为每个部分设置名称):
And C# file (You must set name for every Section):
private void CoinsHub_SectionsInViewChanged(object sender, SectionsInViewChangedEventArgs e)
{
if(CoinsHub.SectionsInView[0] == TransactionsHubSection)
{
QuickAppBarButton.Visibility = Visibility.Collapsed;
AddAppBarButton.Visibility = Visibility.Visible;
CalcAppBarButton.Visibility = Visibility.Collapsed;
}
else if (CoinsHub.SectionsInView[0] == OverviewHubSection)
{
QuickAppBarButton.Visibility = Visibility.Visible;
AddAppBarButton.Visibility = Visibility.Collapsed;
CalcAppBarButton.Visibility = Visibility.Collapsed;
}
else
{
QuickAppBarButton.Visibility = Visibility.Collapsed;
AddAppBarButton.Visibility = Visibility.Visible;
CalcAppBarButton.Visibility = Visibility.Visible;
}
}
这篇关于将不同的 CommandBar 添加到 Hub 元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
更多推荐
[db:关键词]
发布评论