WPF with code only

I saw a lot of questions about the benefits of WPF here, and essentially every answer says it's bee knees, but essentially every answer also talks about things like XAML, in many cases graphic designers and Expression Blend, etc. My question is, is it worth looking into WPF if you are only a cellular encoder that works only in C #?

In particular, I do not have a graphic designer or any great talent in this area; I do not use point-and-click tools; I write everything in C #, not XML.

Winforms works great under these conditions. The same applies to WPF, or it turns out that important functions can only be performed in XAML, the default settings are not intended for actual use, and you must have a graphic designer on the team to make everything look good, etc .., and someone in my position would be better off sticking to Winforms?

+6
c # winforms wpf
source share
6 answers

Short answer : yes, you can only do WPF with code.

Longer answer . The part about the designer who can work with the user interface and the developer in terms of functionality is actually just a side effect of untying the functionality from the presentation.

What WPF brings to the table in a powerful way is data binding, which allows you to use a wider range of design patterns. MVVM was discussed recently.

  • The various MVVM frameworks support a configuration convention that allows you to write less code to achieve the same goals.
  • This denouement also has a nice side effect to make your application more reliable (you do not need to write tests if you do not want this, but at least there is an option).

Moving to WPF from WinForms will most likely cost you for a new development. You could in theory continue to do what you did with WinForms (only with new libraries), but this gives you the opportunity to include new tools in your development when you become more comfortable with technology.

If you haven’t seen this before, Scott Hanselm’s BabySmash series is quite interesting.

+4
source share

I am the code itself, and frankly, it does not matter. Even if you don't know anything about graphic design, you can use the editor in visual studio to develop a user interface. The designer has a drag & drop constructor, as Win Forms does, so this really does not create a problem. Despite the fact that I am a person with code, I have no problems with xaml, as this is, in some way, the code again. At first I had problems with xaml, but I got used to it, and all I had to do in the code in Win Forms was pretty simple in xaml.

Data binding is just a rock, you don’t have to worry about getting data in the user interface, you just have an ObservableCollection<T> or the like, and one property in the xaml code, and everything is done for you. Want to format the data? Just add the formatting property to the binding. Want to color the text according to the meaning? Template selection class with 15 lines of code, binding and template selection in xaml code of the order of 10 lines. I am really happy to love it, and over time (as with any other new technology) you get used to it and create good things.

+6
source share

IMHO, it's worth going along the WPF route, if only to ensure that you build these skills. I played with Silverlight, based on XAML, and I could transfer most of this knowledge to WPF, although SL is a subset.

And to be honest, when you get used to it, most user interfaces are built as easily with WPF as they are with WinForms. And the toolkit is pretty nice, using SketchFlow for prototyping is useful and does not require that you have any real art skills other than what you have for working with WinForms. I believe that in the future it will be useful for me to learn more about WPF, and I believe that this will be the case for others.

+3
source share

Everything that can be done in XAML can also be done in code due to the fact that XAML is just a DSL for creating and setting up graphs of objects, in particular, in the WPF library ( System.Windows ). If you are building business applications, then very little of what WPF offers is not available at all in WinForms. The main difference is that WPF allows you to do much more easily and flexibly due to its more advanced object model.

I think WPF is definitely worth exploring, but if you want to do it without learning XAML, then I think you will probably find the grok more difficult.

It is also worth considering that many WPF developers write XAML manually (while their fellow developers will use Blend more often in the first instance), partly because of the need (the WPF developer before Visual Studio 2010 was not very good) and partly because the object model lends itself to shorter expressions in XAML than in C #. XAML itself is a fairly small language, but the object model that it uses to define it (the WPF object model) is huge - and that is where complexity arises.

If you have no good reason to stop using WinForms, then no. However, if you can cast aside your preconceptions about writing code in XML rather than in C #, then I think you may be wondering how this other approach to creating a user interface can clear your code.

+3
source share

I say that WPF may be for you, and if you do not want to go the xaml path and do the code, you have to go ahead and do it, some things are impossible in xaml, but this is the preferred way to make a layout, but no one forces you to do this in code, however, if you learn xaml, you will create user interface elements faster, then you will be in code to remember something.

+1
source share

This is an old post, but ... In my opinion, there are no errors when you code yourself in any environment and that you always need to find something. In the past, people created layouts in code, but some factors motivated the community to create graphical and ui tools. But then again, nothing lasts forever, and trends change rapidly. Also remember to switch from ASP native coding to ASP.NET layout style, and then back to ASP.NET MVC native. Was that a step back? Of course not, because it was supported by other methods and tools, such as a razor, dynamic language, model bindings, and more. So, in fact, no one can tell you the right way to work, as long as you follow the basic rules and standards and understand that this is not just code, but rather code today, with all lambdas, linqs, expressions, anonymous, DLR, etc. . Who knows? Perhaps you will be the one to create a new way of expressing and managing content.

0
source share

All Articles