vir
vir

Reputation: 1091

how do i set PageOrientation.Landscape in programmatically? Windows Phone 8 C#

i want to put fullscreen icon bar to play video in full screen,

for what i take application bar button :

private void BuildLocalizedApplicationBar()
        {
            // Set the page's ApplicationBar to a new instance of ApplicationBar.
            ApplicationBar = new ApplicationBar();

            // Create a new button and set the text value to the localized string from AppResources.
            ApplicationBarIconButton appBarButton = new ApplicationBarIconButton(new Uri("/images/AppbarIcon/wallpaper.png", UriKind.Relative));
            appBarButton.Text = "FullScreen";
            ApplicationBar.Buttons.Add(appBarButton);
            appBarButton.Click += appBarButton_Click;
        }

then i write click event to make it work : when we click, i want page as Landscape :, i am able to do using emulator right side button, but not able to do via code :

  void appBarButton_Click(object sender, EventArgs e)
            {
                //SupportedOrientations = SupportedPageOrientation.Landscape;
                this.Orientation = PageOrientation.Landscape;
            }

and when PageOrientation changed, i want to fire this event : it will be fire, when i doing from emulator right side button.

private void PhoneApplicationPage_OrientationChanged(object sender, OrientationChangedEventArgs e)
            {
                if (e.Orientation == PageOrientation.Landscape ||
                    e.Orientation == PageOrientation.LandscapeLeft ||
                    e.Orientation == PageOrientation.LandscapeRight)
                {
                    TitlePanel.Visibility = System.Windows.Visibility.Collapsed;

                    player.Height = Double.NaN;
                    player.Width = Double.NaN;

                    player.VerticalAlignment = System.Windows.VerticalAlignment.Stretch;
                    player.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;

                    SystemTray.IsVisible = false;

                }
                else
                {
                    TitlePanel.Visibility = System.Windows.Visibility.Visible;

                    player.Height = Double.NaN;
                    player.Width = Double.NaN;

                    player.VerticalAlignment = System.Windows.VerticalAlignment.Stretch;
                    player.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;

                    SystemTray.IsVisible = true;
                }
            }

Upvotes: 0

Views: 1226

Answers (1)

David To
David To

Reputation: 547

This code will make your page landscape:

void appBarButton_Click(object sender, EventArgs e)
{
   this.SupportedOrientations = SupportedPageOrientation.Landscape;
   this.Orientation = PageOrientation.Landscape;
}

Upvotes: 3

Related Questions