在Windows 8应用程序的全球应用程序栏 [英] Global App bar on windows 8 application

查看:180
本文介绍了在Windows 8应用程序的全球应用程序栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

搜索结果
我工作在Windows 8应用程序项目。我使用Visual Studio 2012和它的预定义模板(GroupedPage,SplitPage,ItemsPage)。结果
。在这个时候,我需要添加一个应用栏。我选择的方式是创建一个和所有网页的显示。我这篇文章readind: http://msdn.microsoft.com/en -us /库/窗/应用/ XAML / jj150604.aspx 结果

要包括这在我的项目,我设置的全球页面启动在App.xaml中页

To include this on my project, I set the Global page as start page on the App.xaml

protected async override void OnLaunched(LaunchActivatedEventArgs args)
...
  if (!rootFrame.Navigate(typeof(GlobalPage), args.Arguments))
                    throw new Exception("Failed to create initial page");
...

在全局网页,我改变了方法OnLaunched,在为了得到真正的主页:

On the Global page, I'm changing the method OnLaunched, in order to get to the real main page:

 rootPage = e.Parameter as Page;            
            frame1.Navigate(typeof(MainPage), this);



我添加事件订阅的按钮,像

I add event subscription for buttons, like

 private void ButtonBlogList_Click(object sender, RoutedEventArgs e)
        {
            this.Frame.Navigate(typeof(BlogListManagement), this);
        }



启动应用程序后,将显示应用程序栏,我可以与导航应用按钮内部,但第一导航之后,AppBar不显示目标页面上。


我的错误的任何想法?结果
感谢您的帮助。

After launching application, the App bar is displayed, and I can navigate with the app button inside, but after the first navigation, AppBar is not displayed on the target page.

Any idea of my mistake ?
Thanks for your help.

推荐答案

您想要做的是设置AppBar上LayoutAwarePage因为所有的网页从该网页派生。
对于AppBar的内容,您可能需要使用一个用户控件,易于编程和造型

What you want to do is to set the AppBar on the LayoutAwarePage since all pages derives from that page. For the AppBar's content you might want to use a UserControl, for ease of coding and styling.

首先创建用户控件:

<UserControl
x:Class="AppBarGlobal.AppbarContent"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:AppBarGlobal"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="300"
d:DesignWidth="400">

<StackPanel Orientation="Horizontal">
    <Button
        Content="1"
        Style="{StaticResource AppBarButtonStyle}" />
    <Button
        Content="2"
        Style="{StaticResource AppBarButtonStyle}" />
</StackPanel> </UserControl>



然后在LayoutAwarePage的构造函数要创建AppBar,设置内容到用户控件,并将其添加到您的网页上BUTTOM或TopAppBar - 在此示例中我使用了BottomAppBar并在consturctor设置全部的寄托,是这样的:

And then in the constructor of the LayoutAwarePage you want to create the AppBar, set the content to the UserControl, and add it to your Buttom or TopAppBar on the page - in this sample I use the BottomAppBar and set everthing in the consturctor, like this:

    public LayoutAwarePage()
    {
        bar = new AppBar();
        bar.Content = new AppbarContent();
        this.BottomAppBar = bar;
        //and the remaining code for the constructor hereafter.

这应该让你有你的Windows应用商店的应用程序中的全局应用程序栏上的所有派生页面从LayoutAwarePage。

This should allow you to have a Global App bar inside your Windows Store app on all the pages that derive from LayoutAwarePage.

这篇关于在Windows 8应用程序的全球应用程序栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆