User Controls Combining WPF and Windows Forms


V The Windows Forms Integration Library

V Using WPF controls in Windows Forms

V Using Windows Forms controls in WPF

V Integration library limitations

Chapter 15 looked at advanced features of Windows Forms. One of these features goes well beyond Windows Forms: user controls. User controls are used in Windows Forms, ASP.NET, WPF, and Silverlight. The concepts around user controls reflect a best practice for encapsulating application logic within a reusable component. Within an application, smaller components that encapsulate functionality and communicate via a method such as events provide a robust architecture. This chapter acts as a bridge to the next chapter which deals with WPF and also references using a user control.

The same concept is used to provide a migration path from Windows Forms to Windows Presentation Foundation (WPF). WPF was first introduced in .NET 3.0 as Microsoft's next-generation solution to graphical user-interface development. In terms of user interfaces, the transition to this new model will be similar in significance and paradigm shift to the shift from COM-based Visual Basic to Visual Basic .NET. The core paradigms and syntax familiar to developers of Windows applications are changing, and most of the changes are not backwardly compatible.

As a result, developers will need to transition existing application source code to a new technology paradigm. Perhaps not this year or next, but at some point the WPF paradigm will be used to update the look and feel of existing applications. How will this transition compare to the last major .NET-related transition — the one from COM? The original version of Visual Studio .NET included a tool to aid in migrating code from the COM-based world to .NET. No migration tool will be provided to transition existing user interfaces to WPF, which should be considered a good thing, considering the history of the current migration tools.

Instead, Microsoft learned the lesson that migration is both difficult and time consuming and is best done at the developer's pace. Therefore, instead of trying to automatically process code based on a procedural paradigm to work under a declarative paradigm, the tool of choice is one that enables components built in the respective paradigms to communicate. After all, in some cases a change like this results in a complete rewrite of an application or the application UI, and the migration library will never be used.

This same interoperability paradigm is repeated in the Power Pack tools for Visual Basic, which Microsoft first released in 2006. These tools, covered in Appendix B, are similar in concept to the Interop methodology that Microsoft has chosen to follow with WPF.

Microsoft is providing libraries that enable user-interface developers to integrate these two user-interface models (WPF and Windows Forms). In the long run, Windows Forms to WPF integration will probably go the way of COM-Interop, which is to say it will be available for many years, but its limitations and ties to an older technology will reduce its influence, and eventually it will be forced into retirement with the older technology.

The focus of this chapter is how to use the Windows Forms Integration Library to best enable you to both leverage WPF with your existing code and leverage your existing code and related forms-based code with your new WPF applications. Just as with COM-Interop, the point of the integration library is to help you, the developer, transition your application from Windows Forms to WPF gradually, while working with the time and budget constraints that all developers face and potentially waiting for a control that isn't available in WPF.

0 0


  • eden berhane
    How to combine wpf and windows form?
    6 years ago
  • Awet
    How to combine the wpf to windiws form application in visual basic?
    3 years ago

Post a comment