简体   繁体   English

使用C ++ / CX for Desktop Windows的XAML应用程序

[英]XAML apps using C++/CX for Desktop Windows

I have experimented with XAML UI programming using C++ for Windows 8 Store apps. 我已经尝试使用C ++ for Windows 8 Store应用程序进行XAML UI编程。 I really like the developer experience, the XAML designer and the fact that I can get pure native apps with a modern rich user interface and high performance. 我非常喜欢开发人员的体验,XAML设计师以及我可以使用现代丰富的用户界面和高性能获得纯本机应用程序的事实。

I want to create similar XAML apps using C++ for Desktop Windows (the non-Store world). 我想使用C ++ for Desktop Windows(非商店世界)创建类似的XAML应用程序。 How do I do this? 我该怎么做呢? For years I have waited for a native UI stack for Windows Desktop which is newer than MFC and somewhat higher level than direct Win32/GDI programming. 多年来,我一直在等待Windows桌面的本机UI堆栈,它比MFC更新,并且比直接Win32 / GDI编程更高级别。

Both Silverlight and WPF use XAML along with code-behind to implement apps. Silverlight和WPF都使用XAML以及代码隐藏来实现应用程序。 Neither are still maintained but if you want to play with the same technology, it's there. 两者都没有维持,但如果你想使用相同的技术,它就在那里。

As Jeff McClintock mentioned, Microsoft has announced that a future update to Windows 8 will allow apps to run on the desktop, but I expect that this will merely be a windowing change and the apps will still run in the restricted sandbox that Store Apps run within. 正如Jeff McClintock所提到的,微软已宣布Windows 8的未来更新将允许应用程序在桌面上运行,但我预计这仅仅是一个窗口更改,应用程序仍然会在Store Apps中运行的受限沙箱中运行。 Maybe Microsoft will introduce yet another desktop-based UI framework and support it for three years before killing it. 也许微软将推出另一个基于桌面的UI框架,并在杀死它之前支持它三年。

WTL is newer than MFC, although its last update was six years ago. WTL比MFC更新,尽管它的最后一次更新是在六年前。 I personally recommend Qt, as it allows access to native Win32 calls (so you can do whatever ganky stuff Win32 apps normally want to do) while still having a rich, robust UI framework to build upon. 我个人推荐Qt,因为它允许访问本机Win32调用(所以你可以做任何通常想做的ganky东西),同时仍然有一个丰富,强大的UI框架来构建。

Codejock has some markup language support in MFC (native C++). Codejock在MFC(本机C ++)中有一些标记语言支持。

http://www.codejock.com/inc/img/downloads/samples/toolkitpro_markupsample_full.png http://www.codejock.com/inc/img/downloads/samples/toolkitpro_markupsample_full.png

该图显示了Codejock Markup Sample

A future update to Windows 8.1 will allow Windows 8 Store Apps to run in a Window on the Desktop, and appear on the taskbar like a Win32 Application. Windows 8.1的未来更新将允许Windows 8商店应用程序在桌面上的窗口中运行,并像Win32应用程序一样显示在任务栏上。 This allows Store apps to Act a lot like Desktop Apps. 这允许商店应用程序像桌面应用程序一样行动。 MS have hinted store-app XMAL will be available to Desktop apps at some point in future. MS暗示商店应用程序XMAL将在未来某个时候可用于桌面应用程序。

http://www.gottabemobile.com/2014/04/02/microsoft-listens-to-users-start-menu-and-windowed-apps-are-on-the-way/ http://www.gottabemobile.com/2014/04/02/microsoft-listens-to-users-start-menu-and-windowed-apps-are-on-the-way/

What I am looking at is C++/WinRT for native C++ applications that use the WinRT framework for UWP apps, at least for Windows 10. See C++/WinRT in the Microsoft Dev Center for a starting place. 我正在看的是用于UWP应用程序的WinRT框架的本机C ++应用程序的C ++ / WinRT,至少对于Windows 10.请参阅Microsoft开发人员中心的C ++ / WinRT作为起点。

C++/WinRT is an entirely standard modern C++17 language projection for Windows Runtime (WinRT) APIs, implemented as a header-file-based library, and designed to provide you with first-class access to the modern Windows API. C ++ / WinRT是Windows Runtime(WinRT)API的完全标准的现代C ++ 17语言投影,实现为基于头文件的库,旨在为您提供对现代Windows API的一流访问。 With C++/WinRT, you can author and consume Windows Runtime APIs using any standards-compliant C++17 compiler. 使用C ++ / WinRT,您可以使用任何符合标准的C ++ 17编译器编写和使用Windows运行时API。 The Windows SDK includes C++/WinRT; Windows SDK包含C ++ / WinRT; it was introduced in version 10.0.17134.0 (Windows 10, version 1803). 它是在10.0.17134.0版本(Windows 10,版本1803)中引入的。

The intro article in the series goes on to say: 该系列的介绍文章继续说:

For authoring and consuming Windows Runtime APIs using C++, there is C++/WinRT. 对于使用C ++编写和使用Windows运行时API,有C ++ / WinRT。 This is Microsoft's recommended replacement for the Windows Runtime C++ Template Library (WRL) and C++/CX. 这是Microsoft推荐的Windows Runtime C ++模板库(WRL)和C ++ / CX的替代品。

I first got started with UWP apps for Windows 10 using C++/CX which uses the Microsoft Visual Studio C++ extensions with ref and all of the C# like extensions for C++ in a .NET world. 我首先使用C ++ / CX开始使用Windows 10的UWP应用程序,它使用带有ref的Microsoft Visual Studio C ++扩展和.NET世界中C ++的所有C#扩展。

I am now working with Visual Studio 2017 and the C++/WinRT framework which uses native C++17 features along with an SDK. 我现在正在使用Visual Studio 2017和C ++ / WinRT框架,它使用本机C ++ 17功能和SDK。 I believe you can also use C++/WinRT with Visual Studio 2015 with the latest updates, update 3. 我相信你也可以在Visual Studio 2015中使用C ++ / WinRT和最新更新,更新3。

There is also a package available from Extensions and Updates within Visual Studio, C++/WinRT, which contains a couple of Visual Studio templates for a couple of different application types. Visual Studio中的扩展和更新提供了一个包,C ++ / WinRT,它包含几个用于几种不同应用程序类型的Visual Studio模板。

C++/WinRT seems to be a work in progress. C ++ / WinRT似乎正在进行中。 It seems best if you are using Visual Studio 2017 with the latest Windows 10, Version 1803, which contains the SDK and the XAML editor works fine. 如果您使用Visual Studio 2017与最新的Windows 10,版本1803,其中包含SDK和XAML编辑器工作正常,这似乎是最好的。 I have had problems with the XAML editor with an earlier build of Windows 10 Enterprise at work (IT Services maintains its own update servers and is a couple of builds behind the bleeding edge). 我在使用早期版本的Windows 10企业版的XAML编辑器时遇到了问题(IT服务部门维护着自己的更新服务器,并且是后面的几个版本)。

See also my question synchronizing SDK with Windows 10 update and using WinRT with Standard C++ which has an updated version of a test program from this article, C++ - Introducing C++/WinRT . 另请参阅我的问题, 将SDK与Windows 10更新同步,并将WinRT与标准C ++一起使用,该标准C ++具有本文中的测试程序的更新版本, C ++ - C ++ / WinRT简介

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM