Differences between revisions 8 and 14 (spanning 6 versions)
Revision 8 as of 2016-09-12 23:50:45
Size: 1588
Editor: scot
Comment:
Revision 14 as of 2016-09-13 00:13:55
Size: 3409
Editor: scot
Comment:
Deletions are marked like this. Additions are marked like this.
Line 31: Line 31:
'''Property-Element Syntax''': '''Property-[Element|Attribute] Syntax''':
Line 37: Line 37:
E.g.:
Line 39: Line 38:
 * {{{<Frame.Content> ... </Frame.Content> is a ''property element''  * {{{<Frame.Content> ... </Frame.Content>}}} is a ''property element''
Line 42: Line 41:
'''XAML Compiler'''
Line 43: Line 43:
Page 145

You can force your output to compile the XAML instead of using it directly. This saves time and space, but is new and therefore suspect. Add the following line to your Assembly.cs file in the properties folder.

{{{#!csharp
[assembly: XamlCompilation(XamlCompilationOptions.Compile)]
}}}
Line 46: Line 53:
=== Program Baskervilles === === CodePlusXaml ===
Line 48: Line 55:
Page 41. Page 140
Line 52: Line 59:
 1. Shows that text wraps inside a label be default.
 1. Shows the use of Device.OnPlatform for padding.
 1. Shows how to create a XAML page in an existing document
 1. Shows code behind
 1. Shows XML namespaces required.
    1. xmlns="http://xamarin.com/schemas/2014/forms"
    1. xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" NOTE: the x: is by convention, so you should use it that way, but it is not strictly required that the name be x.
 1. Shows how to define the class that the objects defined in this fill will belong to:
    1. x:Class="CodePlusXaml.CodePlusXamlPage"
 1. Shows where generated code can be found and how to expose it.
    1. In Visual Studio, in the Solution Explorer, select the CodePlusXaml project, find the icon at the top with the tooltip Show All Files, and toggle that on.
    1. .xaml.g.cs where the g is for generated.
    1. See obj/Debug folder for generated files for XAML
 1. A simple way to identify the Content - its available, just make sure to cast it correctly.

=== ScaryColorList ===

Page 146.

Concepts:

 1. Shows how to do {{{OnPlatform}}} in XAML
 1. Shows how to nest object elements, property attributes and property elements properly.
 1. Shows code behind concepts
 1. introduces the concept of a default property (p. 151) and the {{{ConntentPrpoertyAttribute}}}.
Line 57: Line 85:
 1. Label is demonstrated.  1. {{{OnPlatform}}} class was used (as a variation of the {{{Device.OnPlatform(...)}}})
 1. ... otherwise no new classes demonstrated.

=== TextVariations ===

Page 152

 1. Shows various ways of formatting text in XAML.
 1. if you prefer to use multiple lines, you should left justify the whole paragraph in the XAML file surrounded by quotation marks. (See page 154).

Chapter 7 Notes

Title: XAML vs. Code

Summary

  • XAML is a better way to write up the "view" part of MVVM.
  • XAML is used to write the tree-structured visual user interface

Concepts Not in programs

Converter Classes

Page 134

Below the Color class has a TypeConverter attribute added. Attributes in this context means that the defined attributed class is added to the decorated class. That means that you may have additional properties because of the decoration. You might say that Color now has a TypeConverter object that is instantiated with a Type - in this case the: typeof(ColorTypeConverter)

This, of course, means that Color has additional functionality! We'll learn more about this later!

   1 [TypeConverter (typeof(ColorTypeConverter))]
   2 public struct Color
   3 {
   4 
   5 }

Property-[Element|Attribute] Syntax:

Page 136

This section spells out how to translate some of the code we are used to writing into XAML. Specifically it identifies how XML elements and attributes map to objects and contents.

  • <Frame ...> ... </Frame> is a object element

  • <Frame.Content> ... </Frame.Content> is a property element

  • In <Frame VerticalOptions="Center" ...> ... </Frame>, VerticalOptions is a property attribute.

XAML Compiler

Page 145

You can force your output to compile the XAML instead of using it directly. This saves time and space, but is new and therefore suspect. Add the following line to your Assembly.cs file in the properties folder.

   1 [assembly: XamlCompilation(XamlCompilationOptions.Compile)]

Programs

CodePlusXaml

Page 140

Concepts:

  1. Shows how to create a XAML page in an existing document
  2. Shows code behind
  3. Shows XML namespaces required.
    1. xmlns="http://xamarin.com/schemas/2014/forms"

    2. xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" NOTE: the x: is by convention, so you should use it that way, but it is not strictly required that the name be x.

  4. Shows how to define the class that the objects defined in this fill will belong to:
    1. x:Class="CodePlusXaml.CodePlusXamlPage"

  5. Shows where generated code can be found and how to expose it.
    1. In Visual Studio, in the Solution Explorer, select the CodePlusXaml project, find the icon at the top with the tooltip Show All Files, and toggle that on.

    2. .xaml.g.cs where the g is for generated.
    3. See obj/Debug folder for generated files for XAML
  6. A simple way to identify the Content - its available, just make sure to cast it correctly.

ScaryColorList

Page 146.

Concepts:

  1. Shows how to do OnPlatform in XAML

  2. Shows how to nest object elements, property attributes and property elements properly.
  3. Shows code behind concepts
  4. introduces the concept of a default property (p. 151) and the ConntentPrpoertyAttribute.

Classes:

  1. OnPlatform class was used (as a variation of the Device.OnPlatform(...))

  2. ... otherwise no new classes demonstrated.

TextVariations

Page 152

  1. Shows various ways of formatting text in XAML.
  2. if you prefer to use multiple lines, you should left justify the whole paragraph in the XAML file surrounded by quotation marks. (See page 154).

ManagingAndProgrammingMobileApplications/Xamarin/Chapter 7 (last edited 2016-09-13 00:13:55 by scot)