Very often on this forum there are questions that start this way.

I am writing an application on WinForms. [...]

I personally tried to write on the Win Form and WPF, and, as it seemed to me, WPF is more accurate, more beautiful in terms of the design of UI elements. In addition, WPF comes with a great Xaml language, which is much easier to work with than with C # code inside WinForms.

In this regard, I wonder: what advantages does the Win Form have over WPF and why do many people write on the Win Form, although they have an outdated design and they are not supported?

Closed due to the fact that it is necessary to reformulate the question so that it was possible to give an objectively correct answer by the participants of Streletz , insolor , default locale , VenZell , Eugene Krivenja 21 Jul '17 at 13:11 .

The question gives rise to endless debates and discussions based not on knowledge, but on opinions. To get an answer, rephrase your question so that it can be given an unambiguously correct answer, or delete the question altogether. If the question can be reformulated according to the rules set out in the certificate , edit it .

  • four
    Ask those who write on forms. - Monk
  • 3
    I think there is a convenience and a matter of habit. I have a friend, still can not penetrate into WPF, it is not clear for him, not convenient ... When everything is the opposite for me, I in WPF can mess things up on a design that I’d hardly ever do on WinForm. Just as not cool, applications on WPF are more demanding of computer resources, and sometimes this is simply not required, "Down with beauty, the main thing is that it would work stably and quickly." Let's say some sort of software for accounting or something like that. - EvgeniyZ
  • 3
    They write on WPF, more like, and more than on WinForms. On the WinForms label, 1565 questions, and on the WPF 2270 label. Draw your own conclusions. - VladD
  • Someone else writes on WinForms ?! I last saw WinForms in 2010. And then already WPF was and everyone was thinking about how to go to it. - abg

4 answers 4

WPF has a lot of advantages over WinForms. I would especially call the notion of binding ( Binding binding) and DataContext , which radically facilitate the writing of well-structured programs, in which the presentation is separated from the model, business logic and content.

(Not that it was impossible to write correctly on WinForms, it is much more complicated and requires manual work.)

But the consequence of this and the other side is the much higher complexity of WPF as a framework, a much higher threshold for entering WPF and the correct programming techniques on it. After all, the power of WPF is manifested exactly when you start to separate content from presentation, without it it is not much better than WinForms.

Those who have programming experience on MFC or similar UI frameworks, it is much easier to switch to almost the same WinForms than to learn new (at least more convenient and productive) concepts that help easy, convenient programming on WPF.

I think this is the main reason why WinForms still exists.

  • five
    Many people once programmed the molds with the mouse in VB 5, VB 6, Delphi 3, Delphi 7, so WinForms is immediately familiar with them, understandable and familiar - Andrew NOP
  • @Andrey In WinForms, you can also program. - Alex78191
  • 2
    @Andrey Exactly. Absolutely all the early gooey frameworks are thin wrappers on standard Windows controls that have existed since Windows 1.0. Therefore, they all look like two drops of water. Over time, frameworks have become overgrown with concepts that do not exist in standard controls (those do not even have alignment), but they have not gone far. WPF is a revolutionary step forward, a fundamentally different approach to building an interface. Using it "like WinForms" is almost impossible. Because of this abyss, everyone is lazy. - Athari

I do not know how the others, but personally I don’t remember the moment when I used WinForms last time, if the desktop is just WPF and no matter how pompous it sounds, in this environment it is still ahead of the rest of the planet. It does not matter if it is a bloody enterprise or an application with "butterflies and flowers".

  • Declarative programming, web-like layout model.
  • Independence from resolution, hardware acceleration, support for multi-touch input.
  • Styles, triggers, patterns, animation, audio and video, commands, powerful binding system, routed events.
  • Advanced drawing features.
  • Applications with paging organization.

and a whole lot. In addition, the ideas, principles and philosophy that underlie this technology are very appealing to me, close and appealing. At the same time, I am not some kind of ardent opponent of WinForms or a WPF fanatic, but just to ponder for a second and think about what it would be worth doing on the “forms” what WPF takes 5 or 10 minutes, you unwittingly understand all the power and possibilities, which this technology provides.

At the same time, like everything mundane, WPF is not perfect and not without flaws, but it's just that it’s all the more good and it's a fact.

    Most likely, these are beginners who are just starting to learn .NET. Naturally, they start with a simpler learning WinForms. And it doesn't matter to them that something is outdated there, not supported, etc. Their goal is to learn how to write programs.

      Regarding the outdated design, I did not understand you ...

      As for Win Forms support, it seems to me that it has not gone away; you can be sure of this by reading the news about Visual Studio 2017 and .net 4.7.

      Personally, my observations:

      WPF speaks of tremendous speed in drawing elements on the screen through working on DirectX. My computer is beautiful to everyone - both the CPU and the GPU, but, in fact, the drawing on the screen of Win Forms is much faster (GDI is also not worth it).

      The WPF Control DataGrid is extremely raw (at least a couple of years ago). This is the most important control for presenting data in general. It should be very versatile, just like it is in Win Forms, but not in WPF. For data virtualization in a DataGrid (WPF), you can only use virtualization of the data source itself via a DataSource.

      In Win Forms with a DataGridView, you can do literally anything you want thanks to the good old event mechanism (CellVlueNeeded and CellValueFormating), and it’s very simple (well, DataSource is also in place).

      By the way, can someone tell me, is there a way in the DataGrid to programmatically put focus on line number N without resorting to code in 30 lines using reflection?

      In my humble opinion, WPF is good for applications where flying and flying buttons in the form of stars are more important than anything else.

      For business applications, everything else is important; people use these applications for a long time, many hours a day. Their functionality is complex and, as a rule, non-standard. Therefore, their interface should be as functional as possible and not delay attention to itself. A person should not get tired of the colorful and cartoon interface.

      In favor of WPF, I will only say that the very principle of constructing an interface in it is very interesting in that it is similar to that in Internet pages. This is very interesting, but still damp (until now! When was WPF first introduced!?) ... And yes, I do not like XAML.

      -;)

      • Comments are not intended for extended discussion; conversation moved to chat . - Nofate ♦