Designing XAML User Interfaces from a Different Perspective

XAML brings many benefits to developing user interfaces, but requires you to take a different approach to laying out the controls on the page and interacting with the code-behind. If you primarily develop Windows Forms applications, you are probably used to simply dropping controls on a form and pushing data into them from the code-behind. Essentially, you are probably used to the code-behind controlling the user interface, with the user interface functioning in a subservient role.

While this structure is still possible in Silverlight, the power of XAML enables the user interface to take the controlling role, with the code-behind (or a ViewModel, which is a part of the Model-View-ViewModel [MVVM] design pattern) merely supporting it. This requires a mental leap, because your user interface should now pull the data into itself—a concept enabled by XAML's advanced data binding capabilities.

This new perspective for designing and structuring an application requires a new supporting pattern, and this comes in the form of the new MVVM design pattern. The primary reasons you'd want to use this design pattern are to help maintain a clean separation between the designer and developer components of a project and to design a more testable application than was previously possible. We'll cover this pattern in depth in Chapter 13, but in the meantime, to keep the number of new concepts being demonstrated at any one time to a minimum, we'll discuss the more familiar and easier approach of simply using the code-behind to support and control the user interface.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
52.15.160.43