Windows GUI: WPF or WinRT (2015+)

C#WpfUser InterfaceWindows RuntimeWindow

C# Problem Overview


I am trying to get an overview of the different technologies, to use when building GUI's in the Windows World.

For context, I am building a little 2d platform multiplayer game. (Just for learning purpose..)

My teacher says that he think that WPF is the right way to go, but it seems that he only compare it to Windows Forms.

My understading is, that here in 2015, Windows Forms is totally dead?

In this other stackover questions, they say WinRT+XAML is for Metro GUI building(Window 8 tiles thing!), and it seems that WPF is something used only for desktop in Window 7/8 and are close related to Silverlight..

https://stackoverflow.com/questions/7416826/how-does-the-new-windows-8-runtime-winrt-windows-store-apps-compare-to-silve > - The desktop is where the old apps live (red. WFP). > - The new class of applications, Metro applications, can be built in a number of ways, > including by VB.NET, C# or C++. These three language options can use > XAML for building the UI. The alternative is to use > JavaScript/HTML5/CSS for the development of both the UI and > application code.

My real question is: Isn't there ONE good way to build GUI's in the Window World?

And if not, which technologies should one use on Window 7, Window 8(Desktop and Metro), Window Phone, (And Windows 10!), and even x-box..

Is it to different technologies to be compared this way?

What do you think is the right thing to invest time in?

C# Solutions


Solution 1 - C#

There's a lot here, but here goes:

  • Is Windows Forms (Winforms) dead? No. Its still actively supported. That said, its a horrible technology to work in (at least once you know the magic of WPF)
  • If you want to build a nice-looking, well designed desktop (classic, not Metro) app, WPF is the answer in pure .NET terms. You can use WinRT APIs (such as their socket classes) but you can't run them on OSs before Windows 8. The UI is still WPF.
  • WinRT Apps are for the Windows 8 Store (they are also available in the Windows 10 Store). You can't use WPF here, or WinRT on the desktop, so where you deploy determines what you use. You are correct in your understanding of the languages/technologies available.
  • Windows Phone 8 (now deprecated) uses a modified runtime of WinRT (this has changed in Windows 10). For Win8/WP8, you can use "Universal" apps to share most of the code between a standard WinRT app and a windows phone app.
  • Windows 10 uses the Universal Windows Platform (UWP) which is based on WinRT. Code developed for Windows 10 can also be used on Xbox One, Windows 10 Mobile, and HoloLens. WPF is still for "standard" desktop apps.
  • Xbox is tricky. XNA has gone away, and Microsoft seems to be going away from community created content for the platform. That said, Unity3D can deploy to Xbox, and I believe standard DirectX (C++) development works for it. Universal Windows Platform apps can also be deployed on the Xbox One, and this seems to be Microsoft's strategy going forward.
  • As of 2021, WinUI 3 is a new UI framework that brings the UI framework of UWP to "desktop" apps. This technology will let you deploy to Windows 10 and 11. Existing XAML UWP apps can generally be easily ported to WinUI 3 by changing to the new namespace. If starting an application today, I would seriously consider going this route. It is part of the Windows App SDK.

As far as what to spend time on, that depends on what you are targeting :). Learning WPF/UWP + XAML will yield you a lot of benefits if you want to stay "current" in .NET GUI development, so thats what I would go for. WPF has the most features, so by starting there you just have to find workarounds for what is missing in UWP (or any other XAML based tech).

If you do that, make sure to learn the MVVM (Model-View-View Model) pattern. It works really well with the XAML based technologies, and allows you to share a lot of logic between your WPF and UWP applications. The same logic can also be used if you eventually develop Xamarin applications for iOS/Android, etc.

Note that for true game development, you'll want an actual game framework (like Unity3D or even XNA). You can do it in WPF, and that's a better choice than Winforms, but neither are really meant for games.

Solution 2 - C#

It's quite an old thread, but like I ran into this through google (out of interest), maybe someone else could reach here as well. This is a question that is asked again and again by new programers. So I'd like to answer few things as well, now that Windows 10 is officially released.

Firstly, one shouldn't start with Windows Forms anymore. It's most mature technology for now, but there won't be any further development of Windows Forms, it's only in maintenance stage now. WPF is actively developed (last I read). But now, the Windows Universal Apps (WinRT one) no longer need to be used in full screen, and can be used in windowed mode just like other desktop apps (WPF & WinForms). This increases their usability a lot on non-tablet computers. I believe this will be the future for desktop apps as well. Although, WPF softwares are the traditional desktop apps (with no permissions thing, only UAC). Either way, no matter you learn WPF or WinRT (using .Net) development, you'll end up learning both. They both are XAML + C# (or some other .Net language). I was just learning WPF when WinRT came out with Windows 8. I felt right at home, only few minor changes that you get used to very soon. Not sure about the MVVM scenario (data-binding) in WinRT though. I'm still learning that aspect of WPF myself.

Window 10 has just launched. Windows 8/8.1 didn't see as much success as Windows 7. So if you want to build an app that has a wider audience, you should go with WPF for now. But in near future, WinRT will be the way to go.

For your question, "which technologies should one use on Window 7, Window 8(Desktop and Metro), Window Phone, (And Windows 10!), and even x-box.", the single answer is Windows Universal Apps. This is the exact reason this framework was developed. One technology to be used to develop apps for all devices. Desktop, Tablet, Phones (including Android using Xamarin bundled with Visual Studio 2015), Xbox, and IoT (Internet of Things).

Solution 3 - C#

I will try to answer only one of your question:

Is Windows Forms is totally dead?

No, Windows forms technology is not dead. I will tell you why. WPF and XAML is very comprehensive and complex technology and you can build very nice UI. But! This technology requires deep knowledge. For basic layouts, you don't need so much knowledge, but for some advanced layouts you should have deep knowledge and when I started with this technology and spent lot of time searching some tips on google. So when I need some simple Forms for user input I am always choosing Windows Forms technology which is very simple and straightforward. This is also reason why this technology was very successful when come to the world. When you start with WPF you also need to know what is MVVM design pattern and some not experienced programmers are confused with that.

Solution 4 - C#

It's now April 2016 and there is still no clear answer to this. We are developing a very modern real-time performance monitoring desktop application that has to render multiple charts and displays, intermixed with text and various other graphics. Our application is C#, WPF with .NET Framework 4.5.2 but we are still writing some components using WinForms and GDI+ to get performance that is acceptable. We just haven't achieved it with WPF. We've even developed a couple of displays in the application with DirectX but that adds a lot of complexity that only a few of the team can support. The simplicity and pure speed we can get from hosting a WinForms display within WPF and speed of GDI+ gives us what we need at the expensive of the pure View/ViewModel structure along with have to deal with various airspace issues. Our application is pretty specialist and I'd love to get rid of WinForms altogether but unfortunately this is just not yet possible in our case. For pure performance you will need to go either DirectX or WinForms.

Solution 5 - C#

My two cents... if you want true universal apps, meaning programs that can run on ANY desktop operating system including Windows, WinForms is still the way to go. Just make sure you stay CLR compatibile, and you can deploy on Mac and Linux via Mono. A huge benefit. XAML may be cool, but it's not going to get ported to other operating systems.

I personally find the sandboxed (quicksanded?) UWP business model terrifying; it counters the openness that Windows has stood for since the very beginning.

Solution 6 - C#

I have been working with Microsoft technologies over 10 years. The most important thing I had learnt is not to just listen to what Microsoft is offering you. When Microsoft is saying this is the future, it has 50% chance to go wrong. Microsoft for sure will do the best they can to promote the products that they had invested on, but that doesn't mean that you should follow. See what happen to WCF and Silverlight.

Although WPF is a very nice platform to learn, it has a huge learning curve. I don't think any developer with less then 5 years programming expereience can do WPF right.

By following the MVVM pattern, you will find that doing something relatively easy in WinForm can become very challenging in WPF. Like color a cell based on some condition after a update, or scroll a row in the view and heighlight it.

Of course you can say that you don't have to do MVVM. Just put your code in code behind and make it work. Yes that will work, but what's the point of using WPF? Why not just use Win Form?

Solution 7 - C#

This is an old thread but an important one with the current progress of the .NET framework, c# features, and increased focus on c# as a game development choice.

WPF is almost never chosen as a c# game platform in all honesty. WPF airspace issues scared people off quite fast. I don't think many (if any) major titles or main stream game engines support WPF as a target platform either due to this. WPF makes for a great platform for game launchers though!

WinForms, while now under maintenance-mode, will still be a valid choice for years to come. It's time-tested and stable. From what I've seen, even in 2017, WinForms is still the most common platform chosen for c#-based game development.

Looking at Steam Hardware Survey data you can see that at the time of writing this answer (July 2017), Windows 10 64-bit is now the dominate PC gaming platform at 50% market share, followed by Windows 7 64-bit at 32% and Windows 8.1 64-bit at almost 7%. All other OS platforms market share is so small it's barely worth considering anything other than these three.

With that being the current state of PC gaming, WinForms is the most common denominator to target all 3 top PC platforms. Looking to the future, UWP will be the best target platform for c# game development as Windows 7 and 8 lose significant market share to Windows 10, unless a new platform comes along that replaces it. So that's just by the numbers.

If choosing based on best level of compatibility per OS platform instead of supporting maximum market share, the choices would be more like:

  • Windows 10: UWP
  • Windows 8.1: WinRT or Windows Store
  • Windows 7: WinForms

Most of the other answers center around standard windows application development but game development is a very different realm and different factors will influence your choices, such as target OS and what your choice of graphics API or game engine actually support best.

Solution 8 - C#

WinRT has been on the desktop for a long time, I'm writing WinRT, that runs on my deskop. And under Windows 10, those applications will support non-docked locations (windowed as you might traditionally know them).

I wouldn't recommend WinForms or WPF to anybody starting out today. They should learn WinRT / XAML primarily. And learn some Win32 / .net as they need it, depending on their language of choice..

"they say WinRT+XAML is for Metro GUI building(Window 8 tiles thing!)" -- This is such an over-abstraction, that it's useless. WinRT is a runtime, like Win32, it's not just for GUI, so what "they say" is complete BS. XAML is a UI layer (much like XAML in WPF) but to say it's Metro GUI is also wrong, there is no such thing as Metro GUI anymore. XAML is the Windows UI Layer. And "Windows 8 tiles thing!" is expressive of certain peoples tunnel vision. It would be like me saying Win32 is a start menu thing. You can see how ridiculous that statement is.

Solution 9 - C#

I run into this question some one year ago. I camed to the conclusion that wether XAML, WPF nor WinRT are the correct developing environment to start with.

I highly recomand using .Net Framework for data layer (including Web Services and RESTful layer (JSON) ) and pure HTML5/CSS3 and Javascript for your web presentation layer.

Within Windows 10 you can integrate any web application as a metro application just out of the box.

WinRT, XAML, WPF and similar ms stuff run only on windows and has alot of limitations.

So after one year I'm still very happy about my decision to not use WinRT or XAML for my new project.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAlf NielsenView Question on Stackoverflow
Solution 1 - C#BradleyDotNETView Answer on Stackoverflow
Solution 2 - C#Prateek JainView Answer on Stackoverflow
Solution 3 - C#Tomáš OpisView Answer on Stackoverflow
Solution 4 - C#GarethView Answer on Stackoverflow
Solution 5 - C#user6809202View Answer on Stackoverflow
Solution 6 - C#Jason ChingView Answer on Stackoverflow
Solution 7 - C#Mike JohnsonView Answer on Stackoverflow
Solution 8 - C#Gavin WilliamsView Answer on Stackoverflow
Solution 9 - C#KhamisView Answer on Stackoverflow