Search This Blog

Wednesday, October 9, 2013

Working on my first WPF application from scratch

At work, the project I manage (MVC web app has a WPF installer) had a couple of installer related issues.  I've been on this project ~2 years  and up to now I had no reason to modify the WPF installer app.  I need to determine if the project is going to keep the WPF installer or go with a NSIS based installer.  I reviewed the code and came to the conclusion I know very little about WPF.

So last Friday, I started a small WPF project.  I have a little Lego Parts app I have rewritten a couple of times that currently has a WinForms MDI UI.  Obviously my Lego app needs a WPF UI client.

I thought I would capture my thoughts on WPF.

WPF Cons

  • On controls, renamed Text properly to Content.  This is just annoying.
  • Not all controls (example DataGridColumn) have a Name property.
  • XAML - Maybe unfair on day 1 to say this and yes I'm using yesterday;s tech with VS 2010 but it can be so sloooooow.
  • Property windows for WPF controls/Pages etc...  is terrible.  No really good way to getting to the properties I really use often.
  • Unavoidable not annoying differences in names of method and properties differences between a WPF control and its WinForm counterpart.
  • WPF UI is still a bit slower than its WinForms alternative even on a i7 CPU 3.3 Ghz with a middle of the road video card.


WPF Pros

  • XAML - (4 hrs in).  Now I get it.  Once you know a control / page / window property you want to modify just edit the XML.  This is a huge time saver for repetitive tasks.  Plus this compensates for the terrible VS 2010 properties sheet UI.
  • UI elements.  I like page view paradigm.  
    • I really like DataGrid.  Fantastic that the grid keeps its position when itemsource is updated.
  • Extracting InvokeRequired from UI.  This is completely different in WPF but I like the change. It should never have been married to the Control in WinForms.
  • Data Binding approach is streamlined and simple.
  • Basic settings for UI controls moves so far beyond WinForms.  Colored backgrounds, transparency etc...


Bottom line, in under 8 hours, I managed to restructure an existing C# solution to keep the existing WinForms UI project, move common code out of WinForms UI project, and create the basic elements of WPF UI in a new project.