【问题标题】:ApplicationView does not contain a definition for GetForCurrentView?ApplicationView 不包含 GetForCurrentView 的定义?
【发布时间】:2014-04-11 18:41:09
【问题描述】:

我目前正在关注 MSDN 上的一个教程,该教程不太清楚我遇到的问题是他们建议我使用的方法显然不适用于该类

这里是教程的链接:http://msdn.microsoft.com/en-us/library/windows/apps/dn495655.aspx

这是我正在使用的代码

在我的 App.Xaml.cs 而不是我的主页中,我有一个事件处理程序

   public App()
        {
            this.InitializeComponent();
            Window.Current.SizeChanged += Current_SizeChanged;
            this.Suspending += OnSuspending;
        }

下面是存根方法

 void Current_SizeChanged(object sender, Windows.UI.Core.WindowSizeChangedEventArgs e)
    {
        // Get the new view state but its not allowing me to use getforcurrent state
        // almost like it doesn't exist
        string CurrentViewState = ApplicationView.GetForCurrentView().Orientation.ToString();

        // Trigger the Visual State Manager
        VisualStateManager.GoToState(this, CurrentViewState, true);

    }

如果其他人按照本教程进行操作,他们可以告诉我出了什么问题吗?

  • 是不是我把代码放错页了
  • 我缺少图书馆吗

我逐字逐句地关注这个微软教程,它给了我一个错误,这是我已经完成研究的帖子的标题,我使用的是最新版本的 Visual Studio,但它仍然不允许我使用这种方法,因为它显然不存在

【问题讨论】:

  • 您学习的教程适用于 Windows 8 现代应用程序。您将此问题标记为与 Windows Phone 8 相关。那么您正在为哪一个开发?
  • 我似乎犯了一个错误我目前正在开发教程中显示的空白应用程序页面(平板电脑)

标签: c# visual-studio-2012 windows-8 orientation


【解决方案1】:

尝试使用 Windows.UI.ViewManagement;在程序的顶部。

【讨论】:

  • 这应该是答案。谢谢。
【解决方案2】:

此 API 的最低支持版本是 Windows 8.1。因此,您不能将它与 Windows 8 API 一起使用。 MSDN reference

【讨论】:

  • 那么是不是没有办法获得 Windows 8 的等价物
猜你喜欢
  • 2021-04-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-01-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多