This brief course teaches XAML, specifically targeting Xamarin.Forms. We begin with no assumption of prior XAML experience, and we proceed through intermediate/advanced topics including data binding, events, triggers, behavior, and more. We will also demonstrate that anything you can write in XAML can be written in C#.
Introduction to XAML Hi, this is Jesse Liberty from Pluralsight, and this part of our course is called Introduction to XAML. XAML is a markup language, not unlike HTML, but a good bit more powerful. It allows you to declaratively describe how you want your program to work, and it focuses on, and we will focus on, pages, layout for how you put your controls on the page, and views, views of what Xamarin calls, what other frameworks call, widgets and controls. We'll also talk about XAML's support for data binding, a critical ability in programming, and especially in supporting the Model View ViewModel, or MVVM pattern. Xamarin. Forms are a library or a framework by Xamarin for creating Xamarin applications, and they take advantage of Portable Class Libraries, PCLs, and allow you, most importantly, to write once and run your UI anywhere. Let's take a look at a demo, in which we'll create a simple solution, add some views and layout, and for now, we're going to examine a number of things that we're going to explain later.
XAML and MVVM Hi, this is Jesse Liberty for Pluralsight, and this module is XAML and MVVM. MVVM stands for Model View and ViewModel. This is a pattern that grew up with WPF and Silverlight, a couple of Microsoft technologies, and has been around for quite some time, and lends itself very well to Xamarin. Forms, because it depends on data binding and XAML. In MVVM, the M stands for Model, which is your data, the V is for View, which is your UI, your presentation layer, and the ViewModel holds your business logic. Typically we create three folders, one to represent each of these, and typically, the views and view models have a one to one relationship. Let's take a look at a simple demo of MVVM.
XAML Styles Hi this is Jesse Liberty for Pluralsight, and in this module we're going to take a look at styles in XAML. Styles allow you to put all of the formatting and styling information in one place, so that you'll only have one place to change them, and they go into the ResourceDictionary. We're going to take a look at how that's done. Each style has a key and a TargetType, we'll define what those are. And each style has property value pairs inside of elements called setters. So here you see a quick example of what that looks like, and we'll see that in more detail in the upcoming demo. To use a style, you refer to the resource by its key. So notice here the key is myButtonStyle, and in the button you set the style to that resource and that key. Another type of styles are implicit styles where you leave the key off, set the target type, and it applies to everything of that type. And then there's inherited styles that allow you to set a base style, and then inherit from that base style and other styles, saying that the new style is based on the original style. And that allows you to extend the original style with new information. Dynamic styles are incredible powerful, they allow you to create a method in code, and attach that to your dynamic style. And here, we're creating a timer in code, attaching it to a label, and that label is going to show the current data and time. Let's take a look at a demo that shows all four types.