【问题标题】:how do i set PageOrientation.Landscape in programmatically? Windows Phone 8 C#如何以编程方式设置 PageOrientation.Landscape?视窗电话 8 C#
【发布时间】:2014-06-27 23:12:04
【问题描述】:

我想把全屏图标栏全屏播放视频,

对于我采取的应用程序栏按钮:

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

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

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

当 PageOrientation 改变时,我想触发这个事件:当我从模拟器右侧按钮执行时,它会触发。

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

【问题讨论】:

    标签: xaml windows-phone-7 windows-phone-8 microsoft-metro


    【解决方案1】:

    此代码将使您的页面横向:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多