//The constructor. public Screen() { //The container is a grid with 1 or 2 row definitions, and 1 column. //It may have 2 row definitions when an application bar is visible. mPage = new Grid(); mPage.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); mPage.RowDefinitions.Add(new RowDefinition { Height = new GridLength( 1, GridUnitType.Star) }); mView = mPage; //Initialize the application bar and set its visibility to false. mApplicationBar = new Microsoft.Phone.Shell.ApplicationBar(); mApplicationBar.IsVisible = false; ApplicationBarVisible = false; mApplicationBarItemsIndexes = new Dictionary<Object, int>(); /** * This will add a BackKeyPress event handler to the Application.Current.RootVisual, this is application wide. */ (Application.Current.RootVisual as Microsoft.Phone.Controls.PhoneApplicationFrame).BackKeyPress += new EventHandler<System.ComponentModel.CancelEventArgs>(BackKeyPressHandler); /** * This will add a BackKeyPress event handler to the Application.Current.RootVisual, this is application wide. */ (Application.Current.RootVisual as Microsoft.Phone.Controls.PhoneApplicationFrame).OrientationChanged += new EventHandler<Microsoft.Phone.Controls.OrientationChangedEventArgs>(OrientationChangedHandler); }
//The constructor. public Screen() { //The container is a grid with 1 or 2 row definitions, and 1 column. //It may have 2 row definitions when an application bar is visible. mPage = new Grid(); mPage.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); mPage.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); mView = mPage; //Initialize the application bar and set its visibility to false. mApplicationBar = new Microsoft.Phone.Shell.ApplicationBar(); mApplicationBar.IsVisible = false; ApplicationBarVisible = false; mApplicationBarItemsIndexes = new Dictionary <Object, int>(); /** * This will add a OrientationChanged event handler to the Application.Current.RootVisual, this is application wide. */ (Application.Current.RootVisual as Microsoft.Phone.Controls.PhoneApplicationFrame).OrientationChanged += new EventHandler <Microsoft.Phone.Controls.OrientationChangedEventArgs>(OrientationChangedHandler); }
private void BuildApplicationBar() { ApplicationBar = new Microsoft.Phone.Shell.ApplicationBar(); ApplicationBar.ForegroundColor = Color.FromArgb(0xFD, 0xFF, 0xFF, 0xFF); ApplicationBar.Opacity = 0; Microsoft.Phone.Shell.ApplicationBarMenuItem appBarMenuItem = new Microsoft.Phone.Shell.ApplicationBarMenuItem(AppResources.about); appBarMenuItem.Click += ApplicationBarMenuItem_Click; ApplicationBar.MenuItems.Add(appBarMenuItem); }