是WPF应用程序托管代码吗? [英] Is a WPF application managed code only?

查看:226
本文介绍了是WPF应用程序托管代码吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在应用程式中使用WPF。我想用C ++写它。应用程序是否需要管理?我知道我可以混合管理与非托管。

解决方案

您可以轻松地开发99%的WPF应用程序非托管代码,但使其100%非托管是非常困难的。



WPF类没有Guid属性,因此它们不能使用COM。因此,使用100%非托管代码构建WPF对象(如Button和Window)需要一个非托管CLR API。 Hosting API 可能是最简单的,但它仍然有很多工作。



如果您愿意接受99%的非托管代码,只需使用/ clr选项编译您的应用程序,并使用IJW实例化WPF对象和调用类似Application.LoadComponent的方法。 p>

还要注意,WPF绑定到非托管对象需要这些对象完全支持COM,包括IDispatch。


I want to use WPF in an app. I want to write it in C++. Does the application have to be managed? I know that I can mix managed with unmanaged. I'm wondering if I can have the whole application be unmanaged.

解决方案

You can easily develop 99% of your WPF application in unmanaged code, but making it 100% unmanaged is quite difficult.

WPF classes don't have a Guid attribute, so they won't work with COM. So constructing WPF objects such as Button and Window with 100% unmanaged code requires one of the unmanaged CLR APIs. The Hosting API is probably the easiest, but it is still quite a bit of work.

If you are willing to accept 99% unmanaged code, just compile your application with the /clr option and use IJW to instantiate WPF objects and call methods like Application.LoadComponent.

Also note that WPF binding to unmanaged objects requires that those objects fully support COM including IDispatch.

这篇关于是WPF应用程序托管代码吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆