风中狂奔松鼠's profilesquirrel to flyBlogListsNetwork Tools Help

Blog


    September 18

    WPF vs. Windows Forms

    在学习WPF的时候,在网上发现一篇的josh一篇关于WPF与Winform的对比,是针对一位银行IT人员提出的问题,在银行软件系统中,没有必要使用那些功能强大的动画、3D效果,使用WPF代替WinForm的理由是什么,利弊又如何?前几天与总监室一同事讨论时,得知他们的系统现在都是采用WPF,而且他们也建议我们系统也不要再使用WinForm,当时并不太懂WPF,所以也只是听听而已,这几天开始学习,还并未发现这种取代有多大益处,而且原来系统框架以及类库都是使用WinForm开发,继续研究研究回来再定。

    WPF vs. Windows Forms

    During my WPF presentation at the NYC .NET Developer Group, someone asked me a simple yet difficult question.  Allow me to paraphrase: “I work for a bank’s IT department.  We build Windows Forms applications which basically just show large tables of numbers, allow the user to sort them, edit them, etc.  There is some simple business validation in place, and a few other standard LOB-application things you’d expect.  We have no need for UI candy, animations, 3D, etc.  Why should we use WPF and what can I say to management to convince them that we should use WPF in upcoming projects?”

    When he asked that question, I did not have an answer for him.  Ever since that night I have been thinking about it, and even had the chance to discuss it with Tim Sneath; who had some excellent perspectives on the question.  Here is my much delayed answer for the fellow who asked that question.  Please note that the answer I’m about to give does not necessarily reflect Tim Sneath’s opinion of this topic, nor am I claiming that he supports the view I’m about to express.

    WPF is not intended to replace Windows Forms.  I used to think it was intended to be a replacement for WinForms, but it is not.  WinForms is still alive and well, and will continue to be enhanced and supported by Microsoft for years to come.  WPF is simply another tool for Windows desktop application developers to use, when appropriate.  If the type of applications you develop would not benefit from the features found in the WPF platform, then perhaps WPF is not the correct platform for you to use. 

    So when should one use WPF instead of WinForms, and vice versa? 

    First off, WPF is not just for applications which simply require “eye candy.”  That is the most common and frustrating misperception aboutWPF which I’ve encountered.  Sure, WPF has a lot of support for flashy visuals and animations.  But that’s not all it’s good for.  If you’ve worked with WPF for any substantial period of time you are probably well aware of this fact, so I won’t keep harping on the issue.

    WPF is an especially great platform to use if your applications involve various media types.  For example, if you need to incorporate video, or documents, or 3D content, or animated transitions between a sequence of images, or a combination of any of the above.  WPF is also great if you need to create a skinned user interface, or if you need to bind to XML data, or dynamically load portions of a user interface from a Web service, or want to create a desktop application with a Web-like navigation style.

    Another great reason to use WPF is if you have a team of developers who are bored with WinForms and are itching to get into something new and cool.  Of course this is not as powerful and compelling a reason from a business perspective, but nothing promotes employee retention better than keeping the employees interested in their jobs.

    WinForms definitely still has a role to play, despite the fact that WPFhas hit the scene.  If you are building applications with no need for the extensive modern functionality in WPF, then there is no compelling reason to leave behind a time-tested developer-approved platform.  WinForms certainly has more 3rd party controls available, online resources, developer communities, etc. than WPF currently does.  It’s much easier to find WinForms developers than WPF developers.  Also, WinForms currently has a much better design-time experience in Visual Studio than WPF.  That fact alone is a very compelling reason to stick with WinForms for a while.

    Lastly, don’t forget that it is possible to use WPF controls in a WinForms app, and WinForms controls in a WPF app.  If you have a substantial investment in a WinForms code-base, but want to use some aspect(s) of WPF, you can leverage the interop support to make that possible.  Just be sure to read up on the limitations involved with WinForms-WPF interop before getting too far down that path.


    Comments (5)

    Please wait...
    Sorry, the comment you entered is too long. Please shorten it.
    You didn't enter anything. Please try again.
    Sorry, we can't add your comment right now. Please try again later.
    To add a comment, you need permission from your parent. Ask for permission
    Your parent has turned off comments.
    Sorry, we can't delete your comment right now. Please try again later.
    You've exceeded the maximum number of comments that can be left in one day. Please try again in 24 hours.
    Your account has had the ability to leave comments disabled because our systems indicate that you may be spamming other users. If you believe that your account has been disabled in error please contact Windows Live support.
    Complete the security check below to finish leaving your comment.
    The characters you type in the security check must match the characters in the picture or audio.

    To add a comment, sign in with your Windows Live ID (if you use Hotmail, Messenger, or Xbox LIVE, you have a Windows Live ID). Sign in


    Don't have a Windows Live ID? Sign up

    猫 乌索wrote:
    哇,师兄你好好厉害呀!
    Oct. 1
    David Gaowrote:
    师兄?
    汗~一直以为是师姐呢!
    师兄,膜拜啊!~
    Sept. 27
    伟涛 王wrote:
    师兄,厉害!
    Sept. 27
    sophia zhuwrote:
    哇,师兄你好厉害呀!
    Sept. 23
    福亮 高wrote:
    貌似 银行的系统 都是基于 .net 平台的, 师兄 ?
    Sept. 18

    Trackbacks

    The trackback URL for this entry is:
    http://terry-pekingssm.spaces.live.com/blog/cns!3A3A513135FFB834!300.trak
    Weblogs that reference this entry
    • None