动态创建应用程序栏



我想创建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中,我已经创建了具有给定文本和图标的应用程序栏实例。如何在网页中显示这个

我已经解决了我的应用程序栏问题。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)
        {
        }
}

相关内容

  • 没有找到相关文章

最新更新