Our team is experienced working on Winforms and ASP.net projects.
As what other programmers in programmers stack exchange recommend me to jump to WPF for our team next projects instead of using WinForms for our Client based business Applications.
Now i am starting to Develop my first project using WPF, its a little bit tricky for me as its my first attempt to use this.
Can you gave much deeper information why we need to jump to WPF instead of using winforms?
I need to convinced our manager that we can dig on WPF for our client based projects.
We are using VS 2008.
WinForms and WPF are both great frameworks the question is what is best suited to your application. If you need a fluid gui with animated controls and very themable styles, or are just creating a very graphical user interface WPF is very good for that kind of application.
“WPF would be dead in 2022 because Microsoft doesn't need to be promoting non-mobile and non-cloud technology. But WPF might be alive in that sense if it's the best solution for fulfilling specific customer needs today. Therefore, having a hefty desktop application needs to run on Windows 7 PCs with IE 8.
Winforms vs WPF both are mainly used for the same purpose for developing and designing windows applications, but WPF can be used for the web application. The difference between them is scalability, performance as WPF can render fast compared to windows forms, complexity, and support.
Pick up a good MVVM Framework. I personally use Microsoft Prism. For other alternatives, look at this StackOverflow question.
Routed Events are for the view only. For example, if you want to scroll to the end of a multiline textbox when the text changes.
Commands are used to bind events in which the logic resides on the view-model (business logic)... For example, a submit button.
If you have designers on your team, get them to start playing around with Expression Blend and understanding styles/layout. Expression Blend allows you to use sample data to see your applications layout without having to run it all the time.
Understand The difference between ContentControl
and ContentPresenter
.
Understand how ItemsControl
s work. There is a difference between SelectedItem
, SelectedValue
, and SelectedValuePath
.
Look at a lot of exmaples online. Dr. Wpf, WPFTutorial.net, Josh Smith on WPF, etc.
If you plan to take advantage of Code UI Testing (to test the actual User Interface), then make sure to name controls that matter (most MVVM tutorials tell you that you shouldn't have to name any controls). If you don't plan on doing Coded UI Testing, then don't name your controls unless you need to reference them from the view itself.
IValueConverter
and IMultiValueConverter
should only be used to convert properties to view-related items. The most commonly used converter is the BooleanToVisiblity
converter.
TargetNullValue
, FallbackValue
, and StringFormat
are important when using binding. Don't make assumptions that the data being bound will always be available and correct.
You will almost always expose ObservableCollection<T>
or ReadOnlyObservableCollection<T>
from your view-models. Very rarely will you ever return any other type of collection, including an IEnumerable<T>
.
Be careful in choosing your BindingMode
: OneWay
, OneTime
, TwoWay
, OneWayToSource
(WARNING: OneWayToSource is tricky... it still requires a getter because it is not a write-only binding).
A good debugging tool that is free is Snoop. It is similar to a DOM explorer for a running WPF application. A more advanced (and not free) tool that is a bit more powerful is Mole.
That's all I can think of for now... Oh, and if you run into road blocks, StackOverflow is your friend :)
I wrote a series on WPF with MVVM specifically targeting developers who have a Windows Forms background, and are planning to jump ship.
It walks through some of the basics of WPF, showing how it allows you to approach your development differently than Windows Forms, including introducing (gently) templating, commands, and other concepts that tie into the vastly superior data binding in WPF.
This would provide a nice introduction to WPF, and show you why it can be better for business applications than Windows Forms.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With