William's profile願&望PhotosBlogLists Tools Help

Blog


    September 09

    My WPF experience after 1 months+

    I have been playing with WPF for awhile and would like to share some my experience.

    Pro:

    • Very flexible to customize the appearance of controls to create impressive UI control
    • DataBinding is comparatively easier than the WinForm
    • Animation and StoryBoard are great. The animation I have created ( moving a panel from left to right ) is surprisingly easy and the quality is good. I have tried to mimic the same behavior in WinForm; however, the UI keeps flicking/refreshing that annoys me a lot.
    • Components created in WPF can be easily plug into WinForm ( with some cons + bugs stated in Con section)
    • Separate the design of UI from the implementation of functionality ( with DataBinding, Commands )
    • Drawing, Rendering, Transforming in WPF are simple
    • Program can be converted into a Web application interface with not much effort needed.
    • ControlTemplate overriding, Style, as well as Triggers are some of WPF nice features.

    Con:

    • When using WPF together with WinForm, there’s lots of known and unknown issues.
      • Transparency fails to maintain between the WPF components and Winform components (known issue). The WPF component will use black as background color as result.
      • The UI Rendering in XP versus Vista can be different, uncertain, and disaster. One bug has caused me debugging for more than a week! Don't use the property "TransparencyKey" under System.Windows.Forms.Form with ElementHost embedded. This will cause some weird graphic rendering problem in XP (the WPF control will black out in front, and rendered at the back of your Win Form) This uncertain issue arouses my concern that if we want to use it, we better test it well on all different environment and os.
    • Image with GIF format by default in WPF is not playing as PictureBox in WinForm does
    • There’s no build-in masked textbox. What a pity.
    • ElementHost is created in different AppDomain, mentioned somewhere on the web/msdn discussion board. Therefore, there’s some memory cost. At least 20MB will be consumed first.
    • Program takes longer to start up comparing to WinForm
    • It is possible to have memory leak for bad programming practice with the ElementHost as well as WindowFormHost. Some articles on the web could be found on related topic.
    • Lots of books’ authors recommend not to write any user components because we can customize all the WPF controls, but I found this approach makes me difficult to maintain my code
    • XML based programming versus traditional Visual programming in Visual studio.
    • Visual Studio does not provide a good interface to set the event for WPF. You need to type xml code to figure out what event you want to add handle
    • Visual Studio is not consistently rendering the UI correctly to you. Sometimes you need to restart Visual Studio in order to make it work in front of you. This happens more if you are overriding the DataTemplate for some controls or using WinFormHost components

    Note:

    • When using other namespace, don’t forget to specify the assembly name along with the namespace if the assembly is not the same as the namespace.
    • Error messages sometimes is not that clear.
    • WPF is still growing and promising.
    • I have not learned enough about RoutedEvent and DependencyProperties to give any comments.