none
Is WPF as time consuming and troublesome as it appears to be?

    Question

  • I'm hoping that I just haven't stumbled upon a clear explanation on how use WPF. I understand the advantage of flexibility in design but I don't understand why it has to be so much more time consuming and troublesome than creating a WinForm app.

    When creating a WinForm app, if I want to add a main menu, I simply select the tool, drag it over to the form and it snaps into place docked at the top of the form. I can add a status bar which docks to the bottom in a similar fashion. Docking other controls involves little more than setting the Dock property. For example, a WinForm Toolbar just needs to be dragged onto the form. It, too, docks at the top and can be moved using the Dock property. It even includes everything needed to add buttons, textboxes, separators, etc.

    But, WPF is way more complicated. Apparently, I need a DockPanel to dock anything and even that doesn't work. I end up with a StatusBar stuck in the middle even tho I set its DockPanel.Dock property to Bottom. I need to figure out which containers have to be inside what other containers in order to place a control somewhere.

    None of it makes any sense and the browser-based help system provides much less info than the VS2008 MSDN help program. Don't they even provide an Index anymore?

    Like I said, I am hoping I just haven't found the answers. Where can I find a clear explanation on how to use WPF? Does it really have to be this disorganized and time consuming? Is there no such thing as completed controls or does every WinForm-like contol have to be built from scratch in WPF?

    Wednesday, October 06, 2010 4:32 PM

Answers

  • I can't really help but answer this one. In a way, you are right. There are some things about WPF that are more time-consuming than they were in WinForms. Your trouble with the dock panel is only because you haven't learned to use it yet. For me, the best guide was the "WPF Unleashed" book -- it really gives you a solid basis in WPF and seems like it would be good for you. I don't recommend books lightly, either -- the "WCF Unleashed" book was terrible, for example.

    I also do not buy into Microsoft technologies wholesale. I can list a whole bunch of stuff which is horrible in my opinion. I still can't stand the concept of LINQ, for example, not to even get into workflows.

    Here's the best I can do for you in terms of WPF:

    1. The various panels are FAR MORE EASY AND FUNCTIONAL THAN ANYTHING IN WINFORMS. Most tasks that required a good deal of custom code in WinForms are encapsulated in a single type of panel in WPF. Your problem is that you are very new at it and so nothing makes sense...yet. The move from WinForms to WPF is like the move from text editors to word processors. Everyone complained until they realized the power of what they had in front of them. Just like the advent of the word processor, only when you learn to use it will it be quicker and more functional than the old way. Also just like the word processor, there are rare occasions when the old text pad is the best solution (and same for the old WinForms). These cases are very rare.
    2. Your menu example is fine...except that you can't do anything with it. Can you make it work like a ribbon? Can you put a slider inside your menu? I could ask a thousand more questions, but the simple truth is that the menu is a pre-packaged control that has long since fallen out of use. Office 2007 was the beginning of the end for the classic menu, thank goodness. I can make a "menu" in WPF far more easily and more quickly than you can in WinForms. Again, you just need to take the plunge and commit to at least learning what WPF has to offer.
    3. On your journey, do yourself one favor: never EVER EVER use the toolbox or the visual editor to create your visual elements. Always type directly into XAML. Back to the word processor thing, it's kind of like keyboard shortcuts. Everyone always yells at me when I make them hit "ctrl+c" instead of clicking on the copy button...for the first day. After that, they thank me. You will not like typing XAML for the first day, but then you will thank me.

    I know I haven't given you anything substantive, but I hope I've helped a little. Oh, and by the time you have gotten a chance to build your first couple of applications in WPF, you'll realize that my text editor-to-word processor parable is pretty accurate. It really is that big a step forward.

    Good luck to you.


    I do not agree with what you say, but I will defend to the death your right to say it. -- Voltaire
    • Marked as answer by rlarzen Thursday, October 07, 2010 6:02 PM
    Wednesday, October 06, 2010 8:33 PM
  • Regarding the Help system in VS2010, MS is supposed to be doing something about it, in the meantime, MVP Rob Chandler has created a really excellent 'plugin' app that gets back about 95% of the functionality we lost from VS2008:

    http://mshcmigrate.helpmvp.com/viewer

    Also, if you want some fun reading, here's a thread regarding the user response to the 2010 Help System :-)

    http://social.msdn.microsoft.com/Forums/en-US/devdocs/thread/3bcfa7de-8016-46d0-b85a-df9a44c82095

     

    • Marked as answer by rlarzen Thursday, October 07, 2010 6:04 PM
    Thursday, October 07, 2010 12:11 AM

All replies

  • I can't really help but answer this one. In a way, you are right. There are some things about WPF that are more time-consuming than they were in WinForms. Your trouble with the dock panel is only because you haven't learned to use it yet. For me, the best guide was the "WPF Unleashed" book -- it really gives you a solid basis in WPF and seems like it would be good for you. I don't recommend books lightly, either -- the "WCF Unleashed" book was terrible, for example.

    I also do not buy into Microsoft technologies wholesale. I can list a whole bunch of stuff which is horrible in my opinion. I still can't stand the concept of LINQ, for example, not to even get into workflows.

    Here's the best I can do for you in terms of WPF:

    1. The various panels are FAR MORE EASY AND FUNCTIONAL THAN ANYTHING IN WINFORMS. Most tasks that required a good deal of custom code in WinForms are encapsulated in a single type of panel in WPF. Your problem is that you are very new at it and so nothing makes sense...yet. The move from WinForms to WPF is like the move from text editors to word processors. Everyone complained until they realized the power of what they had in front of them. Just like the advent of the word processor, only when you learn to use it will it be quicker and more functional than the old way. Also just like the word processor, there are rare occasions when the old text pad is the best solution (and same for the old WinForms). These cases are very rare.
    2. Your menu example is fine...except that you can't do anything with it. Can you make it work like a ribbon? Can you put a slider inside your menu? I could ask a thousand more questions, but the simple truth is that the menu is a pre-packaged control that has long since fallen out of use. Office 2007 was the beginning of the end for the classic menu, thank goodness. I can make a "menu" in WPF far more easily and more quickly than you can in WinForms. Again, you just need to take the plunge and commit to at least learning what WPF has to offer.
    3. On your journey, do yourself one favor: never EVER EVER use the toolbox or the visual editor to create your visual elements. Always type directly into XAML. Back to the word processor thing, it's kind of like keyboard shortcuts. Everyone always yells at me when I make them hit "ctrl+c" instead of clicking on the copy button...for the first day. After that, they thank me. You will not like typing XAML for the first day, but then you will thank me.

    I know I haven't given you anything substantive, but I hope I've helped a little. Oh, and by the time you have gotten a chance to build your first couple of applications in WPF, you'll realize that my text editor-to-word processor parable is pretty accurate. It really is that big a step forward.

    Good luck to you.


    I do not agree with what you say, but I will defend to the death your right to say it. -- Voltaire
    • Marked as answer by rlarzen Thursday, October 07, 2010 6:02 PM
    Wednesday, October 06, 2010 8:33 PM
  • FIrst off, just to be clear, you absolutely do NOT have to recreate common controls from scratch in WPF.  If all you want is the 'standard' behavior and Look & Feel you get with WinForms, building WPF apps really isn't much different. There are a few things that are a bit more work (for example columned lists) but only because WinForms makes some very constraining assumptions. Once you get a bit more comfortable with WPF you will find the power and flexibility well worth the extra complexity.

    A couple comments on Charles' response:

    Overall, I agree; WinForms is awesome for what it does, but the minute you need to take even a tiny step outside of that (eg. create a custom control, or apply custom L&F to an existing control) it becomes really painful really fast.

    I wholeheartedly second his suggestion of "WPF Unleashed" by Adam Nathan.  I wish I had this book when I first started learning WPF, it is so well-written, straightforward and absolutely stuffed with practical, useful information.

    I agree with his point #3, you really should write some XAML by hand while you're learning (at least), the Visual Studio designer isn't the best (although it is improving). One thing I would add though, Expression Blend is a really good visual designer for WPF apps and is worth a try, some people do everything in it and rarely edit their XAML by hand. 

    Wednesday, October 06, 2010 10:18 PM
  • Agree – “WPF Unleashed” is a great book to get started with WPF, I still use it from time to time. I switched to WPF more than 6 month ago, and I still get frustrated with it occasionally, but I would not go back to WinForms again for any regular UI, no matter how simple the app is because most things are easier (or as easy) in WPF as in Winforms, and WPF gives you the flexibility of customizing the look without writing any special code (I have done that a lot in the past for regular WinForms controls).

     

    Only time I would go back to Winform/GDI I if I need a lot of graphic elements. If you add thousands of Geometries (WPF lightweight graphic element) then WPF does become a bit sluggish.

     

     

     

    Wednesday, October 06, 2010 11:13 PM
  • I hear you. I too am a WinForms programmer trying to switch over to WPF and I have all of the same gripes about it that you have...right down to the help system which I tried yesterday and really disliked. Unfortunately there seems to be no getting around this - you'll just have to bite the bullet and confront this complex new model if you want to reap the rewards. No doubt about it, it's tough going. I think that's why there are still so many WinForms apps coming onto the market. I myself defaulted to WinForms for my last 2 contracts because I just didn't have time to learn WPF with its vertical learning curve. I can see great potential though and a lot of opportunity. Those who have a nifty idea and the know-how to implement it in WPF will certainly put themselves out front in the marketplace. The software business is pure social Darwinism, so jump into the WPF ocean with both feet and don't look back! It's the key to career survival.

     

    -L

    Wednesday, October 06, 2010 11:39 PM
  • Regarding the Help system in VS2010, MS is supposed to be doing something about it, in the meantime, MVP Rob Chandler has created a really excellent 'plugin' app that gets back about 95% of the functionality we lost from VS2008:

    http://mshcmigrate.helpmvp.com/viewer

    Also, if you want some fun reading, here's a thread regarding the user response to the 2010 Help System :-)

    http://social.msdn.microsoft.com/Forums/en-US/devdocs/thread/3bcfa7de-8016-46d0-b85a-df9a44c82095

     

    • Marked as answer by rlarzen Thursday, October 07, 2010 6:04 PM
    Thursday, October 07, 2010 12:11 AM
  • WPF was meant to be a radical step forward from Winforms. It was to (and has) enabled scenarios that were unimaginable using Winforms. Therefore, the design and tooling decisions made around it had to break from tradition.

     

    It is true that the Design Time or “Cider” experience of WPF does not match that you get with Winforms. This is because the team invested in the Expression Blend tool. If you use this tool, you might find that the development experience is not all that bad.

     

    In fact, WPF was designed to solve a classic application development problem - getting developers and designers on the same page. Traditionally (10 yrs ago), designers would "paint" the look and feel of the applications in UI design tools and then "someone" would have to make it consumable by the application. This entire integration cycle has been considerably reduced because now Visual Studio and Expression Blend can load the same project. Take a look at this case study: http://expression.microsoft.com/en-us/cc265104.aspx

     

    Finding help on WPF is fairly challenging. Many people have tried to address this gap through

    Blogs such as these two:

    http://bea.stollnitz.com/blog/

    http://blogs.msdn.com/b/llobo/

     

    And books such as:

    Adam Nathan's Windows Presentation Foundation Unleashed (recommended by Charles and matte303)

    Pro WPF in C# by Matthew MacDonald

     

    And videos such as:

    William Steele's WPF soup to nuts series

    http://blogs.msdn.com/b/wsteele/archive/2007/08.aspx

    http://blogs.msdn.com/b/wsteele/archive/2007/09.aspx

    http://blogs.msdn.com/b/wsteele/archive/2007/10.aspx

    http://blogs.msdn.com/b/wsteele/archive/2007/11.aspx

    http://blogs.msdn.com/b/wsteele/archive/2007/12.aspx

    (Note: The blog posts only have source code) you will have to search for the videos on

    http://msdn.microsoft.com/en-us/events/default.aspx)

     

    And Tutorials such as:

    http://wpftutorial.net/Home.html

    If all else fails, the WPF Dev community seems to be quite strong and supportive. If you ask a well thought out question it is very likely that you will get the help you want.

    These are all useful resources, and the best resource will be one that aligns with your learning style. The good news is that if you stick it out , the returns are bountiful. The apps are pretty, the maintenance is easy (compared to similar Winforms or native apps) and the jobs are also all right.

    Thursday, October 07, 2010 12:24 AM
  • To: Charles Sullivan

    After reading all these helpful and encouraging responses, I purchased WPF Unleashed for my Kindle. Thank you for giving me a thoughtful answer. I was afraid I'd get flamed for the question but I was entirely serious when I asked.

    It would be nice if there was a simple drag and drop way to create a toolbar, for example. It seems that I have to first figure out what goes in what. There's a ToolBar, ToolBarPanel and a ToolBarTray; how do you figure out what goes where? That's a rhetorical question. I won't ask any more questions until I've had a chance to get into WPF Unleashed.

    Thanks for your help.

    Thursday, October 07, 2010 5:40 PM
  • matte303, thanks for your help. I have purchased the book. I've also downloaded a trial version of Blend to get a feel for it.
    Thursday, October 07, 2010 5:42 PM
  • jkristia, thanks for your comments. WPF Unleashed sure does get a lot of recommendations. I'm looking forward to reading it. I can definitely see that WPF adds extraordinary flexibility. It's the steep learning curve that's killing me. As usual, my clients are calling for finished applications yesterday and they promise they'll send me the specs tomorrow. But, I'm gonna bite the bullet LKeene mentioned and go at.
    Thursday, October 07, 2010 5:47 PM
  • LKeene, thanks for your response. You are certainly correct in that sometimes ease of use is better than flexibility, but, as you suggested, I've decided to bite the bullet. It's been very helpful that you all provided useful responses. I was beginning to think I'd accidentally taken stupid pills. It's good to hear others are experiencing the same kind of frustration.
    Thursday, October 07, 2010 5:52 PM
  • matte303, thanks for addressing the Help system issue. It's encouraging to know I'm not alone in this.
    Thursday, October 07, 2010 5:54 PM
  • saurabhmadan, thanks for your input. I have downloaded the Blend trial and will be trying to figure it all out. I've also download WPF Unleashed. You are so right about the WPF Dev community. I am really impressed with all the helpful comments and encouragement I've gotten on this thread.
    Thursday, October 07, 2010 5:58 PM
  • You're welcome, HTH.  One other suggestion I would make (if you haven't already) is get a copy of Kaxaml: http://www.kaxaml.com/

    It's free, very lightweight and functions both as a great learning tool, and a way to very quickly 'try out' some XAML during development. I use it all the time.

    PS. When your using these forums be sure to use the "Vote as Helpful" and "Mark as Answer" buttons when appropriate! EDIT: Never mind, I see you already do, thanks! :-)

    • Edited by matte303 Thursday, October 07, 2010 6:11 PM edit
    Thursday, October 07, 2010 6:07 PM