我已经将我的项目从Windows 8.0升级到Windows 8.1,并得到了一些过时代码的警告。 其中一些我已经修好了,其中一些不是。
这里是最后的警告,我无法修复,找不到任何信息的形象。
所有的警告都提到了同样的方法,它说它已经过时了,我应该怎么做才能得到没有过时的代码呢?
为什么QueryPerformanceCounter和GetTickCount不能保持同步?
使用ant构build猪的难度
在QueryInterface()实现中检查空指针是否值得?
在C ++中获得ring 0模式(Windows)
这里是代码:
警告号码2。
/// <summary> /// Translates <see cref="ApplicationViewState" /> values into strings for visual state /// management within the page. The default implementation uses the names of enum values. /// Subclasses may override this method to control the mapping scheme used. /// </summary> /// <param name="viewState">View state for which a visual state is desired.</param> /// <returns>Visual state name used to drive the /// <see cref="visualstatemanager" /></returns> /// <seealso cref="InvalidateVisualState" /> protected virtual string DetermineVisualState(ApplicationViewState viewState) { return viewState.ToString(); }
警告编号1。
// Set the initial visual state of the control visualstatemanager.GoToState(control,DetermineVisualState(ApplicationView.Value),false);
警告编号3。
string visualState = DetermineVisualState(ApplicationView.Value);
以上所有的代码,对DetermineVisualState方法的调用都被弃用,它提供了直接查询窗口布局的大小,但是这意味着什么呢?
注意:这是LayoutAwarePage,所以我没有在这里写任何代码,这是Windows 8.0的实现。
任何帮助将不胜感激,并提前感谢!
接受非ASCII字符
如何为tabcontrol实现“closures所有选项卡”
如何在Windows上安装节点jscanvas
string安全function与安全增强CRT
Shell从Ruby执行
从MSDN: 如何停止使用LayoutAwarePage
在Windows 8中,Microsoft Visual Studio模板生成LayoutAwarePage类来管理基于ApplicationViewState的可视状态。 在Windows 8.1中,ApplicationViewState已被弃用,Windows Store应用程序的Visual Studio模板中不再包含LayoutAwarePage。 继续使用LayoutAwarePage可能会破坏您的应用程序。 为了解决这个问题,重写视图以适应新的最小视图状态,并根据窗口大小创建事件。 如果您将应用更新为不同的大小,则必须处理Window.Current和Window.SizeChanged事件,以使应用的UI适应新的大小。 我们建议您停止使用LayoutAwarePage,并直接从Page类继承这些类。 以下是如何停止使用LayoutAwarePage:
protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); this.Loaded += PageLoaded; this.Unloaded += PageUnloaded; } private void PageUnloaded(object sender,RoutedEventArgs e) { Window.Current.SizeChanged -= Window_SizeChanged; } private void PageLoaded(object sender,RoutedEventArgs e) { Window.Current.SizeChanged += Window_SizeChanged; } private void Window_SizeChanged(object sender,Windows.UI.Core.WindowSizeChangedEventArgs e) { if (e.Size.Width <= 500) { //visualstatemanager.GoToState(this,state.State,transitions); } else if (e.Size.Height > e.Size.Width) { //visualstatemanager.GoToState(this,transitions); } else { //visualstatemanager.GoToState(this,transitions); } }
在此链接中搜索Retargeting to Windows 8.1 Preview
打开LayoutAwarePage并将DetermineVisualState方法更改为不再依赖于ApplicationViewState,而是依赖于窗口大小。 例如,当您的应用程序窗口宽度小于500像素时可以返回VerticalLayout,当大于500像素时可以返回HorizontalLayout。 由于这种方法是虚拟的,因此它被设计成在需要的时候在每个页面上被覆盖(就像在SplitPage上完成的那样)。 如果您的布局和视觉状态不同,您可以在任何页面上覆盖此项。 只要确保重命名每个页面上的视觉状态以匹配这些新的字符串。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。