Does Wpf Work with C++

Does WPF Work with C++?

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.

WPF with C++, is it possible?

You can use WPF in a managed C++ project, but you're better off keeping your C++ in a separate assembly and referencing it from a C# or VB WPF project.

Any way to use XAML and WPF from native C++ application on Windows x, where x 8?

WPF isn't bound to Windows 8. It's available from Vista on. There are different ways to integrate WPF in an existing MFC application, depending on your application design. You could use ActiveX with .NET interoperability -- or you could implement a client-server architecture using XMLRPC with your program logic residing in the server and interface design in the WPF frontend.

Should a WPF application be written in C++/CLI or C#?

Managed C++ has been replaced by C++/CLI, and "managed C#" is just C#.

I would strongly recommend you to use C# for a new project, and use C++/CLI only when needed. C# has a better support, has a larger user base, and is easier to work with inside Visual Studio 2010.

Additionally, keep in mind that C++ and C++/CLI are two different languages. For my first .Net project, I chose C++/CLI because I already knew C++, and this was a very bad idea: the learning curve from C++ to C++/CLI is similar to learning C# from C++: don't fall into that trap.

is windows presentation foundation available to c++ developers?

.NET can certainly be worked with C++/CLI, and that should extend to WPF as well.

ASP.Net or WPF (C#)?

Reasons to choose WPF:

  • Much faster and easier development than ASP.NET and jQuery
  • Much easier to implement quick incremental background loading of data
  • Much easier to implement client-side caching of commonly used data (important for remote offices)
  • More efficient data transfer from server (can use advanced WCF features unavailable to web browser)
  • Keyboard navigation better, since you can easily define shortcuts, etc, and not be limited by browser
  • Maintenance overhead much better using MVVM pattern
  • Softphone integration easy

Reasons to choose ASP.NET and jQuery:

  • None that I can see

In your scenario I would definitely choose WPF.

Choosing between WPF/C# and Qt/C++

I've used both Qt with C++ and WPF. I much prefer WPF as a User Interface framework. Qt isn't bad, especially post 4.0. I wouldn't even touch earlier versions of Qt.

As others have said in comments, WPF is better documented, and the online community is larger. If you are looking at styled applications WPF is certainly the way to go. Qt's Declarative language which is new is a good step along that road, but because it's so new it tends to be a bit buggy. WPF has been around longer, and is more mature and richer in features.

However, I think the real issue in your case is the c++ code base that you have.

WPF will require a C++/CLI layer (managed C++) in order to interface properly with your c++ code base. This sounds complicated, and does require a little bit of work, but it is not as crazy as it might sound. And there is tons of documentation about this as well. Personally I would stay away from PInvoke.

Qt is a little easier because it is c++ based, but you will have some translation to do between c++ native types, and Qt types (like QString, QList etc...) that are used internally.

Another thing to consider is what look-and feel you would like for your UI. For example if you were thinking about a nice Ribbon (office 2008, 2010) look, then you will not get this with Qt. Also, there are a ton of third-party WPF controls, but I haven't found very many for Qt. In some cases it is very handy to buy a nice set of controls to supplement the ones Microsoft gives by default.

Over the past couple of years where we don't have a requirement to have a linux UI we have been using WPF, regardless of the code base. We haven't regretted it yet.

However, I will also suggest a third option. Code-jock is a UI framework that is based on MFC I believe. It is c++ and ActiveX based. It has become quite sophisticated. Check it out here.

EDIT:
QML has come a long way since I first looked at it. I haven't had the time to look at it in depth, but from what I hear it offers some very interesting features. It is worth an extra look.

Also, as a few comments have indicated, there are more Office-like controls such as a ribbon, and also some diagram and graphing controls that have added to the Qt toolset. These do make Qt an interesting prospect.

I will stand by something I said earlier though, that as a programmer I find making UIs with WPF a whole lot easier, and I am more pleased with my results than anything that I have ever coded with Qt.

XAML or C# code-behind

Creating an entire window in C# can be a mess of code. The best thing about WPF is that XAML allows you to separate your design from your logic, making for much easier-to-read code.

I'll use C# when I need to create dynamic controls, but I tend to keep my general design, static storyboards, styles, datatemplates, etc. in XAML.



Related Topics



Leave a reply



Submit