Chapter 5. Using Content Controls, Items Controls, and Range Controls

,

In This Chapter

Image Element alignment effects on sizing

Image Using buttons

Image Data binding CheckBoxes and RadioButtons to viewmodel collections

Image Binding to the ListBox.SelectedItems property.

Image Using a BackgroundWorker to update a progress bar asynchronously

Image Understanding implicit ListBoxItems


The Windows Phone SDK provides an extraordinarily diverse and rich set of controls, from layout to media controls, form elements suitable for line of business applications, to even multiscale image support (a.k.a. deep zoom). This was made possible by leveraging the existing controls and platform maturity of Silverlight for the browser.

Yet, bringing Silverlight to the phone was no mean feat, and meant that the Microsoft Silverlight team faced the challenge of adapting an existing set of controls, designed for the most part with a web browser experience in mind, to the mobile platform, where it was necessary to contend with differences in display size and resolution, touch support, and so on. Fortunately Silverlight itself has been designed with a seemingly remarkable level of foresight, allowing many controls to be dropped in to the Windows Phone Framework Class Library (FCL) for XAML apps with only minor control template changes.

Accompanying this set of adapted controls are several new controls designed specifically for the phone, including the Panorama and Pivot (covered in Chapter 11, “Creating Expansive and Engaging Apps with the Pivot and Panorama”).

Additionally, Microsoft provides a third set of controls, which are located in the Windows Phone Toolkit (covered in Chapter 9, “Enriching the User Experience with the Windows Phone Toolkit Controls”). It includes controls like the ListPicker, seen in some of the phone’s built-in apps, which provide increased usability and behavior in harmony with the Windows Phone design philosophy.

This chapter begins by providing an overview of the elements available in the Windows Phone FCL. It then focuses on the three base control types: ContentControl, ItemsControl, and RangeBase. It examines the various subclasses of these controls, accompanied with practical examples. It looks at how ContentControls are able to host a single item of content and at the differences between the various button controls, including the HyperlinkButton, RepeatButton, and ToggleButton, and at how each is used. The chapter then ventures into some more advanced topics, such as binding CheckBox and RadioButton controls to viewmodel collections and shows how to bind to the ListBox.SelectedItems property, a feat not readily achievable with the Windows Phone SDK out-of-the-box!

Finally, the chapter explores the RangeBase controls: the Slider and ProgressBar and demonstrates how to provide feedback to a user during asynchronous activities carried out by a BackgroundWorker.

The majority of the source code for this chapter is located in the ControlExamples directory of the WPUnleashed.Examples project, in the downloadable sample code.

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

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