Win8 Metro UI应用的开发是一件非常有趣的事情,特别是它使用了非常奇特的Metro UI设计。如果现有传统UI设计的应用,能够很方便的移植到Win8上,并且也能够充分利用Metro UI的魔力,那么将是非常有有意义的事情。本篇博客就是讲述,在一般情况下,如何将传统UI应用移植成Metro UI应用。
移植工作看上去比较的难,但是按照规律办事,很多事情仅仅是时间和耐心问题。网友不妨使用9步法来完成你的应用移植:
- 下载并安装Windows 8 Consumer Preview,下载并安装Microsoft Visual Studio 11 Express Beta。
- 使用Microsoft Visual Studio 11 Express Beta 创建Metro UI应用程序项目,语言可以选择你自己喜欢的C/C++、C#或者Visual Basic等。
- 将你要重复使用的文件夹、源代码、资源文件等拷贝到你的新项目中,并且在Solution Explorer中选择Show All Filters。
- 用鼠标右键选择你的文件夹、文件等,将其添加入新项目中。
- 使用整个项目的查找替换方法,将System.Windows替换成为Windows.UI.Xaml。
Silverlight XAML namespaces | Windows Runtime XAML namespaces |
System.Windows | |
System.Windows.Automation | |
System.Windows.Automation.Peers | |
System.Windows.Automation.Provider | |
System.Windows.Automation.Text | |
System.Windows.Controls | |
System.Windows.Controls.Primitives | |
System.Windows.Data | |
System.Windows.Documents | |
System.Windows.Input | |
System.Windows.Interop | |
System.Windows.Markup | |
System.Windows.Media | |
System.Windows.Media.Animation | |
System.Windows.Media.Imaging | |
System.Windows.Media.Media3D | |
System.Windows.Navigation | |
System.Windows.Printing | |
System.Windows.Resources | |
System.Windows.Shapes |
- 拷贝能够重复使用的XAML代码到项目的XAML文件中去(你可以根据需要创建新的XAML文件)。
- 编译你的项目,使用错误信息快速定位需要修改的地方。使用Windows Runtime APIs替换元代的.NET APIs。
- 对不能够简替换的代码部分,使用注释将其暂时屏蔽,以便日后慢慢修改。重复7和8的方法直到整个项目完全编译通过。
- 对暂时屏蔽的代码部分逐一解决。完成所有相关的修改后,你的移植工作基本完成,下面的工作就是解bugs了。
怎么样?是不是比较简单!还不现在动手试一试J。