【问题标题】:app bar in windows phone 8Windows Phone 8 中的应用栏
【发布时间】:2014-08-21 16:02:55
【问题描述】:

您好。

我试图向 windows phone 8(VS 2013 和 framework 4.5)应用程序添加一个应用栏。

<phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True" Mode="Default" Opacity="1.0" >

            <shell:ApplicationBarIconButton IconUri="/Images/save.png" Text="save" Click="Button1_Click" />
            <shell:ApplicationBarIconButton IconUri="/Images/delete.png" Text="delete" Click="Button2_Click" />
            <shell:ApplicationBarIconButton IconUri="/Images/help.png" Text="help" Click="Button3_Click" />
            <shell:ApplicationBarIconButton IconUri="/Images/settings.png" Text="settings" Click="Button4_Click" />

            <shell:ApplicationBar.MenuItems>
                <shell:ApplicationBarMenuItem Text="get default size value" Click="MenuItem1_Click" />
                <shell:ApplicationBarMenuItem Text="get mini size value" Click="MenuItem2_Click" />
            </shell:ApplicationBar.MenuItems>

        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>

应用栏按钮显示在此特定页面中,但在其他页面中不可见。我们如何使应用栏及其按钮可见全局

提前致谢 塞巴斯蒂安

【问题讨论】:

    标签: windows-phone-8 appbar


    【解决方案1】:

    您还可以通过编程方式创建它并将对它的引用存储在您的 App.xaml.cs 中,然后将其插入到每个页面的构造函数中,如下所示:

    this.ApplicationBar = App.GlobalAppBar;
    

    创建很简单:

    ApplicationBarIconButton firstButton = new ApplicationBarIconButton();
    firstButton.IconUri = new Uri("/Images/save.png", UriKind.Relative);
    firstButton.Click += Button1_Click;
    firstButton.Text = "save";
    GlobalAppBar = new ApplicationBar();
    GlobalAppBar.Buttons.Add(firstButton);
    

    【讨论】:

      【解决方案2】:

      您需要创建一个可在多个页面上重复使用的全局应用程序栏。通常我们在要使用它的页面上创建一个应用程序栏,并且它仅适用于该页面。为此,这里有一个很好的示例create a global Application Bar ,您需要使用 App.xaml 中的 XAML 创建一个全局应用程序栏,如示例所示。

      or

      您需要在所有单独的页面中编写相同的AppBar 代码,以便按照问题中的描述将其显示到所有页面

      【讨论】:

      • 良好的资源链接;如何将菜单放置在所需位置(页面左上角)?
      • appbar的位置默认固定在页面底部
      • 我们可以使用没有应用栏的菜单项吗?
      • 任何带有一些示例的参考网址都会有所帮助。
      • developer.nokia.com/community/wiki/… 看到这个弹出窗口和这个用户控件geekchamp.com/tips/…
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-08-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多