Windows 8 中的 WinRT 和 WPF
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7697414/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
WinRT and WPF in Windows 8
提问by bstodos
As I understand, WinRT is a different version of WPF written without using the underlying Win32 APIs.
据我了解,WinRT 是不使用底层 Win32 API 编写的 WPF 的不同版本。
What's the relation of WinRT and WPF? Will WPF work under Metro in Windows 7 or will it launch the classic desktop?
WinRT 和 WPF 的关系是什么?WPF 会在 Windows 7 的 Metro 下运行还是会启动经典桌面?
That's not so clear from the Keynote. If someone has Windows 8 installed can confirm it's behaviour.
从 Keynote 讲,这不是很清楚。如果有人安装了 Windows 8 可以确认它的行为。
Thanks
谢谢
回答by Hans Passant
WinRT is a replacementfor the Winapi. The api is native, very unlike WPF that runs as a layer on top of the CLR. It certainly resembles WPF, part of what causes confusion. It adopted the metadata format of managed code, replacing type libraries of old. And uses XAML for UI designs, much like WPF, Silverlight and Windows Phone. You can still write WPF apps for Windows 8 but your app can't be published through the store, won't integrate with the Metro desktop nor will it run on tablets that are based on the ARM core. Whether that's a real problem depends a great deal on how well Metro will do in the market place.
WinRT 是Winapi的替代品。api 是本机的,与作为 CLR 之上的层运行的 WPF 非常不同。它当然类似于 WPF,这是导致混淆的部分原因。它采用了托管代码的元数据格式,取代了旧的类型库。并使用 XAML 进行 UI 设计,很像 WPF、Silverlight 和 Windows Phone。您仍然可以为 Windows 8 编写 WPF 应用程序,但您的应用程序不能通过商店发布,不能与 Metro 桌面集成,也不能在基于 ARM 内核的平板电脑上运行。这是否是一个真正的问题在很大程度上取决于 Metro 在市场上的表现。
回答by Stephen Gennard
Windows Runtime (WinRT) is an alternative API used to create Metro Applications (and later server application).
Windows 运行时 (WinRT) 是用于创建 Metro 应用程序(以及更高版本的服务器应用程序)的替代 API。
The APIs are class/method/struct based and surfaced to .Net metro apps, html5/css3/javascript apps and C/C++ metro applications.
这些 API 是基于类/方法/结构的,适用于 .Net Metro 应用程序、html5/css3/javascript 应用程序和 C/C++ Metro 应用程序。
The implementation is native.
实现是原生的。
APIs are made visible via .winmd files, which contain metadata very similar to the metadata you have in .Net assemblies.
API 通过 .winmd 文件可见,其中包含与 .Net 程序集中的元数据非常相似的元数据。
The APIs are designed to secure and async friendly with many APIs requiring the use of async/await due to them potentially taking more than 50msec to execute.
这些 API 旨在为许多需要使用 async/await 的 API 提供安全性和异步友好性,因为它们的执行时间可能超过 50 毫秒。
It includes a subset of Win32 APIs and COM apis.
它包括 Win32 API 和 COM api 的子集。
Anyway... the followings links help... channel9 also has some //Build/ videos on the subject..
无论如何...以下链接帮助...频道9也有一些关于这个主题的//Build/视频..
Metro style app development - http://msdn.microsoft.com/en-us/windows/apps/
Metro 风格应用程序开发 - http://msdn.microsoft.com/en-us/windows/apps/
Win32 and COM for Metro style apps - http://msdn.microsoft.com/en-us/library/windows/apps/br205757(v=VS.85).aspx
用于 Metro 风格应用程序的 Win32 和 COM - http://msdn.microsoft.com/en-us/library/windows/apps/br205757(v=VS.85).aspx
APIs for Metro style apps - http://msdn.microsoft.com/en-us/library/windows/apps/br211369(v=VS.85).aspx
Metro 风格应用程序的 API - http://msdn.microsoft.com/en-us/library/windows/apps/br211369(v=VS.85).aspx
回答by Akash Kava
There is no relation between WPF and WinRT, just like there is no relation between Silverlight and WPF. Now we have three technologies, WPF, Silverlight and WinRT.
WPF 和 WinRT 之间没有关系,就像 Silverlight 和 WPF 之间没有关系一样。现在我们拥有三种技术,WPF、Silverlight 和 WinRT。
If you try to execute WPF application, it will not execute on Metro, it will execute in the classical desktop only.
如果您尝试执行 WPF 应用程序,它不会在 Metro 上执行,它只会在经典桌面上执行。
In Visual Studio 2011, you have WPF and Metro as two different types of applications, and Xaml for WPF and WinRT is not same, Xaml for WinRT is pretty much same as that of Silverlight as lot of classes which exist for WPF are missing in WinRT library. But most of classes that exist for Silverlight are available in WinRT.
在 Visual Studio 2011 中,WPF 和 Metro 作为两种不同类型的应用程序,WPF 和 WinRT 的 Xaml 不相同,WinRT 的 Xaml 与 Silverlight 的 Xaml 几乎相同,因为 WinRT 中缺少 WPF 的许多类图书馆。但是对于 Silverlight 存在的大多数类都可以在 WinRT 中使用。
回答by Daniel A. White
WinRT is a new library that you can use XAML, but not WPF.
WinRT 是一个新库,您可以使用 XAML,但不能使用 WPF。
WPF is primarily uses DirectX for visual.
WPF 主要使用 DirectX 进行可视化。
You can use WinRT with:
您可以将 WinRT 用于:
- XAML
- C#
- C++
- VB.NET
- HTML/JS/CSS
- XAML
- C#
- C++
- 网络
- HTML/JS/CSS
回答by Stephane Halimi
WinRT is a non managed API based on COM interfaces. You use it by calling objects buit in .winmd metadata files ( Windows\System32\WinMedataData directory).
WinRT 是基于 COM 接口的非托管 API。您可以通过调用 .winmd 元数据文件(Windows\System32\WinMedataData 目录)中的对象 buit 来使用它。
All the namespaces begin with "Windows.".
所有命名空间都以“Windows.”开头。
You can write your Windows 8 application by using XAML files, but that's the only common point with WPF.
您可以使用 XAML 文件编写 Windows 8 应用程序,但这是 WPF 的唯一共同点。