Chapter 7. Bind to the Data
In this chapter, we will cover the following recipes:
- Binding data in code
- Binding data in XAML
- Configuring two-way data binding
- Using value converters
Introduction
As a mobile developer, you create different types of applications and the majority will interact with data; they are data-driven. These apps display and manipulate data from a source, local database, filesystem, or from a remote server. From any type of persistent storage, you create classes that represent the data and in many cases transform and present them to a view. In Xamarin applications, the MVVM pattern is a common approach to design such applications. To learn more about this pattern, refer to Chapter 5, Dude, Where's my Data? and Chapter 4, Different Cars, Same Engine.
How are these data values presented to the view and also pushed back to the source (ViewModel
, Model) when a value is changed? Traditionally, you might set the value to the UI control property and register to a value...