I am new to GUI development
I must warn you that WPF has a really steep learning curve. I would go as far as to say that it's not suitable for the unexperienced.
converting between Winforms and WPF
The problem is not the code in itself. The problem is the mentality with which it is written:
All the "traditional" winforms code behind is absolutely unneeded in WPF.
In WPF, there's DataBinding (well, actually winforms has something called databinding but that's laughable compared to WPF (as much as anything else in winforms). This completely removes the need to create OR manipulate ANY UI Element in procedural code. Everything is defined in XAML and then DataBound to the relevant Models and ViewModels. That's why there's a huge difference in the mentality required for this.
- In winforms, the UI stores information about it's state. In order to read/retrieve/modify this information, you have to access these UI elements in code.
- In WPF, the ViewModel and the Model (simple classes that you create to store your data and that are not tied to the UI at all) store this state information. In order to read/retrieve/modify this information, you do NOT access the UI elements in code.
The WPF Visual Tree is very much more complex than the winforms X,Y approach. Therefore getting a hold of some UI element deeply buried within, let's say a DataTemplate
used for an ItemsControl
which is inside a DataTemplate
used as the CellTemplate
of a DataGrid
is something that you really don't want to get into. Believe me.
I suggest that you read @Rachel's Excellent Explanation and linked blog posts to better understand what's required to transition from the clumsy, boring, too-much-code-for-everything winforms world into the beautiful, customizable, scalable, pleasant world of XAML and DataBinding (applicable to all XAML-Based technologies WPF, WinRT, Silverlight, Windows Phone, etc).
As I envisage my end-product to include animation
If you are about to start (or starting) a new product, forget winforms. It's dead. It doesn't support anything aside from the default ugly stuff. It cannot be customized / animated / beautified without resorting to a lot of horrible hacks.
Everyone will tell you that winforms is only to maintain legacy applications, but no longer an option for anyone who starts any serious project.
However it a complex and lengthy code and as I am relatively more comfortable with winforms
Once you learn MVVM, You will quickly realize that WPF requires 10% of the code required to do anything in winforms. Your complex and lengthy code (probably code-behind) will be reduced to Simple, Simple properties and INotifyPropertyChanged
. That's how you code in WPF.