WP7.托管代码创建菜单栏
publicMainPage()
{
InitializeComponent();
applicationBar=newApplicationBar();
applicationBar.IsVisible=true;
applicationBar.IsMenuEnabled=true;
ApplicationBarIconButtonbtnAdd=newApplicationBarIconButton(newUri("/Images/appbar.add.rest.png",UriKind.Relative));
btnAdd.Text="cancel";
ApplicationBarIconButtonbtnMinus=newApplicationBarIconButton(newUri("/Images/appbar.minus.rest.png",UriKind.Relative));
btnMinus.Text="close";
applicationBar.Buttons.Add(btnAdd);
applicationBar.Buttons.Add(btnMinus);
ApplicationBarMenuItemmenuItem1=newApplicationBarMenuItem("菜单项1");
ApplicationBarMenuItemmenuItem2=newApplicationBarMenuItem("菜单项2");
applicationBar.MenuItems.Add(menuItem1);
applicationBar.MenuItems.Add(menuItem2);
btnAdd.Click+=newEventHandler(btnAdd_Click);
btnMinus.Click+=newEventHandler(btnMinus_Click);
menuItem1.Click+=newEventHandler(menuItem1_Click);
menuItem2.Click+=newEventHandler(menuItem2_Click);
}