Designing and Developing Windows Applications Using Microsoft .NET Framework 4: Designing the Presentation Layer

  • 12/17/2011

Chapter Summary

  • There are two dominant technologies for Presentation layer development—Windows Forms and WPF. Both have inherent advantages and disadvantages. Windows Forms has a strong and dedicated developer base and offers superior globalization and localization technology. WPF is relatively new and has not been adopted as strongly by developers, but it offers substantial improvements in the interactivity of the UI. You can use Windows Forms and WPF controls in the other application type through interoperability.

  • Your UI should be designed with the user in mind. The principles of good UI include:

    • Structure

    • Simplicity

    • Visibility

    • Feedback

    • Tolerance

    • Reuse

  • You should design for inheritance and code reuse whenever possible. Use of resources in WPF and extended controls in Windows Forms are examples of code reuse.

  • Your UI should be designed for accessibility, and thus it should support standard system settings, ensure compatibility with a high-contrast mode, provide keyboard access to all important functionality, provide notification of the keyboard focus location, and convey no important information by sound alone.

  • Application workflow can be simple or complex. For applications that require navigation, Navigation applications in WPF provide a range of options from simple navigation to highly structured branching. Windows Forms applications can use MDI technology for navigation.

  • Data validation is most commonly handled in the Presentation layer. Both Windows Forms and WPF provide technology to create and implement validation rules in your UI. Management of data binding is usually handled through an intermediary class—the DataSource in Windows Forms and ICollectionView in WPF. In addition, WPF provides technology that enables direct binding to XML data.

  • WPF provides a great deal of technology to implement different behaviors in the UI, including attached events, triggers, and animation. Drag-and-drop functionality is very similar in both Windows Forms and WPF.

  • The BackgroundWorker object encapsulates a background task and contains functionality to enable stopping and starting the task, as well as reporting to the main thread. For finer control, Thread objects can be created directly. In Windows Forms, you must query the Control.InvokeRequired property of a control to ensure safe cross-thread access. In WPF, you can use the Dispatcher object for safe cross-thread access.