Chapter 8 Notes

Title: Code and XAML in harmony

Summary

This chapter shows how to create interactions between code and the elements in a XAML file.

Programming Concepts Summary

Programs

ParameteredConstructorDemo

Page 159.

Concepts:

  1. Shows how to include parameters in XAML.
  2. The number and type of parameters must match an existing constructor.

Classes:

No new classes

FactoryMethodDemo

Page 159.

Concepts:

  1. Shows how to create an object using a FactoryMethod.

Classes:

No new classes

XamlClock

Page 161.

Concepts:

  1. Shows a better approach to accessing XAML object/elements by giving them a name.
  2. x:Name="..." is introduced and the text name must meet C# naming rules.
  3. You can find the "magic" in the generated file: XamlClockPage.xaml.g.cs

    1. Every x:Name attribute becomes a private field in this generated code.
    2. Objects named with x:Name will only be available after the call to InitializeComponent.

  4. Includes the concept of a Timer and an OnTimerTick() handler.

Classes:

No new classes

PlatformSpecificLabels

Page 164.

Concepts:

  1. Shows how to create a platform specific Label - but the first go, won't allow you to x:Name them.
  2. Also all the Labels will be created, but only one of them will be assigned to the ContentPage default value - Content.

  3. Also, ContentPage.Content is a View, and consequently the x:TypeArguments="View" - of course this is ok because Label inherits from view.

  4. The solution is to push the OnPlatform into the Label as shown int the final version.

Classes:

No new classes

ColorViewList

Page 168.

Concepts:

  1. CustomViewList shows how to create a custom view that can be used over and over again.

  2. Shows how the CustomViewList has a string property color that uses a Converter

  3. Shows how to use the CustomerViewList in the main XAML page

Classes:

No new classes

XamlKeypad

Page 172.

Concepts:

  1. Assign handlers in XAML

Classes:

No new classes

MonkeyTap

Page 176.

Concepts:

  1. An actual game that brings together all the things we have learned.

Classes:

No new classes

ManagingAndProgrammingMobileApplications/Xamarin/Chapter 8 (last edited 2016-09-14 22:17:27 by scot)