如何以编程方式设置PageOrientation.Landscape? Windows Phone 8 C# [英] how do i set PageOrientation.Landscape in programmatically? Windows Phone 8 C#

查看:762
本文介绍了如何以编程方式设置PageOrientation.Landscape? 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;
        }

然后我编写click事件以使其起作用:当我们单击时,我希望页面为Landscape :,我可以使用模拟器右侧按钮进行操作,但不能通过代码进行操作:

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;
            }

当PageOrientation更改时,我想触发此事件:当我从模拟器右侧按钮执行操作时,它将触发.

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;
                }
            }

推荐答案

此代码将使您的页面保持风景:

This code will make your page landscape:

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

这篇关于如何以编程方式设置PageOrientation.Landscape? Windows Phone 8 C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆