97

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..

How does Windows 8 Runtime (WinRT / Windows Store apps / Windows 10 Universal App) compare to Silverlight and WPF?

  • 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?

Community
  • 1
  • 1
Alf Nielsen
  • 1,361
  • 1
  • 10
  • 19
  • 5
    "WPF or WinRT?". Learn both, WPF for the desktop, Windows Runtime for mobile devices. These technologies have many things in common, like XAML and a very similar framework. You may even write code that supports both platforms, as Portable Class Libraries. – Clemens Feb 18 '15 at 15:11
  • 2
    @Clemens The last bit is a bit misleading. Standard .NET libraries have to be re-built/targeted to work with WinRT apps, which may require code changes for certain classes. – BradleyDotNET Feb 18 '15 at 17:42
  • 3
    Windows Forms is not totally dead but you probably don't want to use it unless you're already familiar with it. – Casey Aug 14 '15 at 03:20
  • 2
    Your objective of "stay current in Windows GUI" is rather harmful in my opinion. There is little future in this for the average developer in the long term. MS has changed its tools for GUI so many times while JavaScript and HTML5 kept in gaining ground. If you are developing for a living forget all else. Few exceptions to this, if you are working for MS, or GUI 3rd party vendor or willing to stuck maintaining old code. – NoChance Mar 12 '17 at 08:50
  • 3
    Even MFC is not totally dead, and not Win32 either. But MFC for a games is what a madmen would pick – Lothar Mar 28 '17 at 23:00

9 Answers9

134

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.

Breece W
  • 3
  • 1
BradleyDotNET
  • 60,462
  • 10
  • 96
  • 117
  • Thanks for the answer, I have for my mini game began with XNA, so i'm sorry to hear they will remove it. But i'm looking forward to see what Windows 10 will bring us. – Alf Nielsen Feb 19 '15 at 16:12
  • @AlfNielsen I'm not sure when end of support is, but it certainly seems they aren't going to be updating it anytime soon. – BradleyDotNET Feb 19 '15 at 16:59
  • 2
    Looks like VS is going for full support of Unity, so kudos on predicting that one! :) – B.K. Apr 18 '15 at 00:18
  • Actually you can use WinRT APIs in desktop WPF application but you will be limited to Windows 8+ – creker May 05 '15 at 08:27
  • @creker While I could imagine using the API (not really sure *why* you would do that, really) thats not the same thing as building a windows store app (using the WinRT *runtime*) for the desktop. – BradleyDotNET May 05 '15 at 16:25
  • @BradleyDotNET, one of my projects required me to develop WindowsPhone and Windows applications that implement custom networking protocol around UDP multicasting. WinRT UDP sockets are really usefull in that case. I know .Net has UdpAnySourceMulticastClient but for some reason it didn't work in some cases. I undestand that in context of UI WinRT and WPF don't mix but other than that APIs are compatible and it can be usefull. – creker May 05 '15 at 18:46
  • @creker The WinRT sockets certainly are nicer. I'll edit my answer to note this difference. – BradleyDotNET May 05 '15 at 18:50
  • 2
    WPF rendering speed using WPF classes like Visual is horrible for games or anything realtime. – wingerse Aug 02 '16 at 18:55
  • @WingerSendon Granted, but there are ways to do pretty efficient 3d (and especially 2d) animations/graphic intensive operations. Not saying I would make a AAA game with WPF, but you can go a lot farther than in WinForms :) – BradleyDotNET Aug 02 '16 at 23:51
  • @BradleyDotNET, that's interesting. I've dug quit a lot, but found no managed way of doing it really. Could you post any link or something? – wingerse Aug 04 '16 at 18:38
  • 2
    @WingerSendon Look at `RenderTransform`, `Viewport3D` and the like. They are hardware accelerated. – BradleyDotNET Aug 04 '16 at 21:08
  • WPF feels like its been abandoned. No StrokeThickness on text after all this time? – patrick Jan 25 '17 at 21:23
  • @Patrick On the contrary, WPF has received updated tooling at the very least in each of the latest versions of visual studio. the lack of StrokeThickness (or good stroke handling at all) is annoying but not needed in the vast majority of projects, so its probably pretty low priority for Microsoft. You can always use `FormattedText` to get the same effect: https://msdn.microsoft.com/en-us/library/ms752098(v=vs.110).aspx – BradleyDotNET Jan 25 '17 at 21:27
  • UWP apps look like normal desktop (WPF) apps on a Windows 10 desktop pc. But they can be directly used on a different UWP-capable device like Windows 10 mobile, XBox One etc. The downside is, they do never have admin privileges. Basically UWP apps are more modern, all hardware accelerated and the apps can be pushed to the Windows Store. But the community is still smaller than WPF and you can not acces the registry or the programs folder. – ecth Mar 16 '17 at 08:29
  • @ecth Or run them on non-windows 10 devices, or (to a certain extent) access random computer resources like serial ports, the hard disk, network ports, etc. (granted, each of those is actually supported with the right, sometimes hidden, permission set). Don't get me wrong, UWP is great, but you have to know who you are building for – BradleyDotNET Mar 16 '17 at 15:31
27

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).

Prateek Jain
  • 388
  • 3
  • 9
  • 20
    Universal Apps don't seem to work on Windows7 or Windows8. "Universal apps" are only "universal" to Win10 devices. – Dragontamer5788 Aug 27 '15 at 23:25
  • Xamarin is still its own thing (no Universal Apps) and I'm not sure they can deploy to Xbox either. – BradleyDotNET Oct 20 '15 at 00:57
  • @Dragontamer5788 Sorry. I strike-out Windows 7. UWP is backwards compatible with Windows 8/8.1 I think. I remember reading it somewhere. – Prateek Jain Dec 12 '15 at 10:31
  • @BradleyDotNET Correct. But most of UWP code (or so they claim) can be reused to develop Android/iOS apps using Xamarin. – Prateek Jain Dec 12 '15 at 10:31
  • 2
    @PrateekJain: NO on running UWP apps on Windows 8: http://stackoverflow.com/a/30317960/199364 – ToolmakerSteve Jun 10 '16 at 16:09
  • 7
    WinForms is still great for quick-and-dirty GUIs - WPF is nice, but requires a lot of boilerplate code (and a steep learning curve) to use "correctly", even without MVVM. It sucks that WPF doesn't have true RAD capabilities - and that XAML is just so danged *verbose*. – Dai Mar 02 '17 at 20:31
  • 2
    For all devices of my arse. It's microsoft speak again at it's finest. Just like in the old days when they called it cross-platform because it was running on Windows95 and Windows2000. The other thing is that i never want Desktop apps have the same ugly sizes of buttons and especially trees and lists that i have to use for touch. THerefore no UWP for me – Lothar Mar 28 '17 at 23:57
25

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.

Jakob Möllås
  • 4,239
  • 3
  • 33
  • 61
Tomáš Opis
  • 289
  • 3
  • 6
  • 4
    This is my favourite answer. For small apps I use Windows Forms because it's so quick and easy to get going. For complex production code I use C++ (with WTL) and side-step .NET entirely. – Robinson Jan 31 '16 at 12:28
  • 9
    For readers not familiar with WPF some clarification - for basic application layouts WPF requires more or less the same amount of effort to make. Default VS WPF application template provides same starting point as WinForms. MVVM is not at all mandatory to work with WPF but actually using Binding without any MVVM framework is also easy for simple apps. WPF is closer technologically to WinRT and UWP so please for your own sake assume Windows Forms is dead for anything else than maintaining legacy applications. – too Feb 05 '16 at 00:26
  • 6
    Winforms is great for building a new age "console" app. Eg extremely basic tab control with a bunch of buttons and user input that effectively puts a skin on what would normally be a console app. – rollsch Oct 11 '16 at 04:39
16

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.

Gareth
  • 251
  • 4
  • 15
  • 1
    I'll give you that *some* things are more performant in WinForms. There are other things (animations in particular) that the reverse is true for. Granted, going to straight DirectX would probably be even *better* but no one wants to do this as you pointed out. – BradleyDotNET Sep 01 '16 at 00:53
  • 1
    After WinRT, I decided to start looking elsewhere. My clients and I cannot rely too much on what Microsoft wants as it effects my and my clients bottom line. I am now looking at a self hosted application which uses a local webserver to serve the application pages locally to the user's browser or embedded browser control in a WinForm/WPF app. This simplifies development, moves me closer to cross platform compatibility, and obviously reduces costs. – TheLegendaryCopyCoder Aug 08 '17 at 13:03
8

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.

5

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?

Jason Ching
  • 1,991
  • 1
  • 19
  • 23
  • 3
    I will agree that WPF has an intense learning curve, but once you get past that, there is simply no going back to WinForms...ever. – Krythic Nov 01 '17 at 05:36
4

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.

Mike Johnson
  • 686
  • 5
  • 13
  • While having a point of view on gamedev is intersting, I don't understand why you would pick a GUI framework for gamedev where you have full featured game engine for C# like Unity. Only few game I saw with classic GUI in it were for game data edition (like map/assets edit) – Uwy Aug 10 '17 at 07:49
  • 2
    For the same reason they pick a game engine: It's quite a bit of work to create and manage a native window effectively from managed code on your own. – Mike Johnson Aug 11 '17 at 11:51
3

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.

Gavin Williams
  • 446
  • 1
  • 4
  • 14
  • 8
    To clarify my original statement, WinRT cannot be used to create a "traditional" desktop application. For that reason, among others, there are *tons* of reasons to learn WPF (WinForms, not so much). If nothing else, you will have effectively learned WinRT at the same time (as I note in my answer). Additionally, we are nowhere near the point of WinRT apps ruling the market (especially line of business apps). WPF is still immensely valuable. – BradleyDotNET Apr 03 '15 at 01:54
  • 7
    If WinRT is not tied to building full screen apps, could you tell me how you can use it to build a windowed app that runs on any actually released version of Windows? Or how to use it to write an app that runs on more than 10% of Windows computers (i.e. Windows 7 and XP)? I am guessing most developers want to be able to target more than 10% of Windows users. Until Windows 8 or 10 get a serious amount of market share, WPF is still going to be necessary for many applications. WinRT may be a runtime layer, but that doesn't change the fact it cannot access many of the things (full) Win32 can. – John Colanduoni Apr 30 '15 at 19:53
  • 1
    @JohnColanduoni as his said, for anyone starting today(Mar14) WinRT is the way to go, win10 was and is free as an update for a few months now, and will be for a few more months, so yes, win10 are grabbing a huge market share. yes not everyone moved to win10, but also a couple of days ago we found out that an airport in France still use win3.1 – John Demetriou Nov 17 '15 at 15:42
  • 1
    @JohnDemetriou All the numbers I've seen put Windows 10 market share at less than even Windows XP. "Not everyone" is putting it lightly. Also, it doesn't bode well for future adoption because Windows 7 and 8 computers already try as hard as they possibly can to get you to upgrade. Windows 10 Universal apps have some benefits like being able to run on a Windows 10 phone (though they'll look terrible if you don't bother to customize the user interface for each), but their disadvantages (small market, 30% of revenue taken by Microsoft) will still outweigh the advantages for a lot of people. – John Colanduoni Nov 17 '15 at 15:49
  • @JohnColanduoni - You're looking at the wrong numbers. I put up some useful information. But the truth can be hurtful, so the mods deleted my response. XP is dead. Basically it's a third-world/warehouse operating system now. It's not a consumer operating system. And the consumer market is not the slightest bit interested in Windows XP. And XP does not factor into the consumer market. XP sits at around 2% in the games market for example. And it's at 0% for the tablet/phone market. Quoting internet based statistics out of context is almost meaningless. – Gavin Williams Dec 05 '15 at 10:26
  • 3
    @GavinWilliams Okay, where are your statistics that put Windows 10 at an appreciable market share in any market segment? Are you saying the mods removed your comment with a link to your source, but they let you put this one up? I'm not buying that. I agree XP isn't worth supporting, but Windows 10 universal apps don't even support Windows 8.1, let alone Windows 7. Adoption is nowhere where it needs to be to justify windows universal, and [it is slowing](http://www.pcworld.com/article/2999901/operating-systems/windows-10-adoption-keeps-slowing-as-microsoft-plans-aggressive-upgrades.html). – John Colanduoni Dec 05 '15 at 10:34
  • 3
    @GavinWilliams Okay, let's ignore that 30% is a *lot* less than 97% (the support you would get if you used WPF), and that this data is only useful for video game programmers. For video games it's quite easy to target both; unless you're doing something really trivial you're going to want to use DirectX/OpenGL, which means you just need to host it in a window/fullscreen. If you don't want to use those, you're *really* going to want WPF since WinRT's UI doesn't allow immediate-mode drawing without hosted DirectX/OpenGL (as WPF does). So what about WinRT justifies a 70% reduction in market size? – John Colanduoni Dec 05 '15 at 11:12
1

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.

Khamis
  • 35
  • 2
  • 3
    What are you talking about? Yes, that's a great choice if you want to make a Web app. If you want to make a desktop app, it is not. You could use Katana and have locally-hosted WebApi and make a desktop app, which I guess would make this answer more relevant. – Casey Jan 30 '16 at 19:20
  • 1
    OP asked about Windows GUI and WPF or Winrt - not Web apps. – ezaspi Feb 23 '16 at 13:45
  • 6
    Also, I personally find those technologies *much* harder to work with (incomprehensible layout system, no compile-time checks on the code, etc.) The desktop isn't dead yet :) – BradleyDotNET Mar 02 '16 at 17:54
  • 1
    I agree, HTML is the universal UI and should be for the desktop too. I feel we need to simplify all these different frameworks, and stop introducing more and more and more and more. Most of it is not needed. Just learn HTML and ASP and then self host your website in a WinForm app. The WinForm app contains your web-server and web browser control. The result is, you save time, you focus on mastering one language and tech, you developer faster, you save your clients money, your apps are future proof and far more portable. – TheLegendaryCopyCoder May 02 '17 at 15:05