【问题标题】:How to create Top AppBar similar to built-in apps in Windows 8.1?如何在 Windows 8.1 中创建类似于内置应用程序的 Top AppBar?
【发布时间】:2013-11-26 04:09:02
【问题描述】:

SportsTravel等内置Windows 8.1应用使用酷炫的顶级多级AppBar。它几乎看起来像是可在任何应用程序中使用的某种标准 UserControl,但我还没有找到任何指南,如何在我的应用程序中简单地添加它。
这真的是某种通用 appbar,还是仅在 Microsoft 应用程序中使用的自定义 AppBar?基本的 CommandBar 没有我所知道的这种样式。

【问题讨论】:

    标签: xaml microsoft-metro windows-8.1 appbar


    【解决方案1】:

    WP 8.1 中有 AppBar 控件,但您可能需要设置其布局和样式。但是您可以从默认样式开始。考虑下面的应用栏示例,其中我添加了一些主要命令和一个辅助命令

    <Page
        x:Class="App1.MainPage"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="using:App1"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="d">
    
        <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
            <TextBlock HorizontalAlignment="Left" Margin="471,258,0,0" TextWrapping="Wrap" Text="Demo AppBar" FontSize="32" VerticalAlignment="Top" Height="64" Width="314"/>
    
        </Grid>
    
        <Page.BottomAppBar>
            <CommandBar>
                <CommandBar.PrimaryCommands>
                    <AppBarButton Icon="Accept" Label="Save"/>
                    <AppBarButton Icon="Cancel" Label="Cancel"/>
                    <AppBarSeparator />
                    <AppBarButton Icon="Add" Label="Add New" />
                </CommandBar.PrimaryCommands>
    
                <CommandBar.SecondaryCommands>
                    <AppBarButton Label="About">
                        <AppBarButton.Icon>
                            <BitmapIcon UriSource="/Assets/Logo.scale-100.png" />
                        </AppBarButton.Icon>
                    </AppBarButton>
                </CommandBar.SecondaryCommands>
            </CommandBar>
        </Page.BottomAppBar>
    </Page>
    

    你不妨看看Windows 8.1 app bar sample

    【讨论】:

    • 我实际上发现这些应用程序中使用的 NavBar 组件仅适用于 HTML Windows 8.1 应用程序,但也许我们会在 Callisto 库中看到此控件的端口。 code.msdn.microsoft.com/windowsapps/…
    【解决方案2】:

    仍在尝试,但我想这是使它看起来像内置应用程序的解决方案: Tutorial for a Top AppBar / NavigationBar

    您可以在 opf 中放置任何您希望的 GUI 元素“AppBar”,甚至可以在右键单击时推出的 AppBar。所以你必须右键单击它2次才能获得所有菜单。

    看起来都一样,因为 MS 都是在自己的工作室里完成的。我认为任何地方都没有资源,因为功能是可能的,但外观应该不同。他们在风格指南中明确建议以不同的方式设计 AppBar 以制作出色的应用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-09-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-03-16
      相关资源
      最近更新 更多