Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does WPF Work with C++?

My understanding is that Microsoft Visual Studio was rewritten to use WPF. I'm still not clear on why, but acknowledge my knowledge about WPF is very limited.

My question is if anyone knows how much support WPF has for C++, and if Visual Studio is still written in C++.

Personally, WPF primarily appears to be .NET/VB/C# thing. Is anyone using it with C++?

like image 264
Jonathan Wood Avatar asked Jan 23 '11 20:01

Jonathan Wood


People also ask

Is WPF only C#?

WPF is used to build Windows client applications that run on Windows operating system. WPF uses XAML as its frontend language and C# as its backend languages.

Is WPF still relevant 2022?

“WPF would be dead in 2022 because Microsoft doesn't need to be promoting non-mobile and non-cloud technology. But WPF might be alive in that sense if it's the best solution for fulfilling specific customer needs today. Therefore, having a hefty desktop application needs to run on Windows 7 PCs with IE 8.

Is WPF still in use?

It was in 2006 that Windows Presentation Foundation (WPF) was released with . NET framework 3.0. Over the years it got improved and it is still now in the market in 2021.

What replaced WPF?

Universal Windows Platform. Both Windows Forms and WPF are old, and Microsoft is pointing developers towards its Universal Windows Platform (UWP) instead. UWP is an evolution of the new application platform introduced in Windows 8 in 2012.


2 Answers

You can use WPF with C++/CLI. It is a .NET API, however, so it requires the .NET Framework.

That being said, the designer support is non-existent with C++. This means that, for practical purposes, WPF doesn't really work with C++.

Typically, the user interface layer is written in C# (or VB.NET), then calls into C++ code, often exposed via P/Invoke or C++/CLI layers. By using C++/CLI, it's very easy to interoperate between C++ code and C#/VB.NET code.

like image 152
Reed Copsey Avatar answered Sep 18 '22 23:09

Reed Copsey


WPF is a .NET technology. Of course it can be used with C++, like any other part of .NET can, but it requires you to jump through some interop hoops, or possibly write it all in C++/CLI. (And you'll have to write a lot of boilerplate code yourself, as the designer doesn't work with C++/CLI.)

And Visual Studio isn't, and probably never was, "written in C++". With 2010, members of the VS team have stated on their blogs that VS is now primarily a managed application. Of course there's still a ton of C++ code in there, and that's not going away any time soon, but a lot of it is C#/VB today.

But that didn't happen overnight. Managed code has gradually been added to Visual Studio with every release. Visual Studio is written in many different languages.

If what you're actually asking is "can I write an addin for Visual Studio using C++", then the answer is "yes".

If you're asking "is it practical to write an application in C++, and still use WPF", the answer is probably "only if you write the WPF code in C#, and then have some interop code binding this together with your C++ app.

like image 36
jalf Avatar answered Sep 19 '22 23:09

jalf