0

我想创建Application Bar dynamically in Windows Phone 8. 我已使用以下代码在 appbar.cs 文件中创建应用程序栏

class AppBar
    {
    public AppBar()
    {
        ApplicationBar appbar;
            this.appbar = new ApplicationBar();
            this.appbar.IsVisible = true;
            this.appbar.Opacity = 1;
            this.appbar.Mode = ApplicationBarMode.Minimized;
            ApplicationBarIconButton appButon = new ApplicationBarIconButton();
            appButon.IconUri = new Uri("/images/show.png", UriKind.Relative);
            appButon.Text = "Show";
            this.appbar.Buttons.Add(appButon);
            appButon.Click += appButon_Click;

        }
     }

        void appButon_Click(object sender, EventArgs e)
        {

        }
}

如果我创建了AppBar 类的实例,则调用了所有方法,但我无法看到应用程序栏。我给了request to create the appbar from webview。从 javainterface 中,我使用给定的文本和图标创建了应用程序栏的实例。如何在网页中显示此内容。

4

1 回答 1

0

我已经解决了我的应用程序栏问题。Added my application bar with parent element(PhoneApplicationPage).

class AppBar
    {
    public AppBar()
    {
        ApplicationBar appbar;
        PhoneApplicationPage parentpage = (Application.Current.RootVisual as ContentControl).Content as PhoneApplicationPage; 
            parentpage.ApplicationBar =  new ApplicationBar();         
            appbar = parentpage.ApplicationBar;
            appbar.IsVisible = true;
            appbar.Opacity = 1;
            appbar.Mode = ApplicationBarMode.Minimized;
            ApplicationBarIconButton appButon = new ApplicationBarIconButton();
            appButon.IconUri = new Uri("/images/show.png", UriKind.Relative);
            appButon.Text = "Show";
            appbar.Buttons.Add(appButon);
            appButon.Click += appButon_Click;

        }
     }

        void appButon_Click(object sender, EventArgs e)
        {

        }
}
于 2013-03-19T08:59:19.060 回答