SlideShare a Scribd company logo
Xamarin.Forms Hands On Lab
2016
PREPARED BY ENG SOON CHEAH , MICROSOFT MVP
ENG SOON CHEAH
XAMARIN MALAYSIA DEVELOPERS
P a g e 1 | 17
XAMARIN.FORMS HANDS
Chapter 1 :
Create your first Xamarin.Forms Application
Chapter 2 :
Pages
 ContentPage (Lab 1)
 TabbedPage (Lab 2)
Chapter 3 :
Layouts
 StackLayout (Lab 3)
 AbsoluteLayout (Lab 4)
 Grid (Lab 5)
Chapter 4 :
Views
 ActivityIndicator (Lab 6)
 DatePicker (Lab 7)
 Editor (Lab 8)
 Picker (Lab 9)
 Switch Cell (Lab 10)
Chapter 5 :
Tutorial
P a g e 2 | 17
XAMARIN.FORMS HANDS
CHAPTER 1: Create Your First Xamarin.Forms Application
In the Start screen, launch Visual Studio. This opens the start page:
2. In Visual Studio, click New Project... to create a new project:
P a g e 3 | 17
XAMARIN.FORMS HANDS
3. In the New Project dialog, click Mobile Apps, select the Blank App (Xamarin.Forms Portable) template,
set the Name and Solution name to Phoneword, choose a suitable location for the project and then click
the OK button:
4. In Solution Explorer, right click on the Phoneword project and select Add > New Item...
P a g e 4 | 17
XAMARIN.FORMS HANDS
5. In the Add New Item dialog, select Visual C# > Forms Xaml Page, name the new file MainPage, and
click the Add button. This will add a page named MainPage to the project:
When it comes to sharing code within Xamarin.Forms applications,you have two
primarily accepted methods:
 Portable Class Libraries
 Shared Projects
Xamarin.Forms and PCLs
Just like any choice you are faced with in software development,there are always
pros and cons to take into consideration. Using PCLs within your Xamarin.Forms
application is no different. While PCLs work very well in Xamarin.Forms
applications,there are a few very important things to consider when choosing them
in your projects:
Pros:
 Can access other PCLs targeting similar frameworks.
 Allow you to use XAML-based views
P a g e 5 | 17
XAMARIN.FORMS HANDS
 Easy to write unit tests to verify functionality.
 Generate an assembly that can be shared in other projects.
Cons:
 Can’t contain platform-specific code.
 Can’t reference any projects or libraries that contain platform-specific code.
 Only contain access to a subset of the .NET Framework.
Xamarin.Forms and Shared Projects
Choosing to use Shared Projects with your Xamarin.Forms application can provide
you with further opportunities to consolidate shared code used by your application.
This further consolidation comes at a bit of a cost,but depending on the type of
application you are building,this cost may be acceptable. In order to make and
educated decision about whether or not you should use Shared Projects,consider
their pros and cons:
Pros
 Have access to all functionality in referencing projects.
 Can contain platform-specific code.
 Support conditional compilation to allow multiple platform-specific code in
a single file.
Cons
 Doesn’t create an assembly, so code can’t be shared to other applications.
 Doesn’t support creating views using XAML.
 Unit testing is more complicated when platform-specific code exits.
P a g e 6 | 17
XAMARIN.FORMS HANDS
Pages
The Page class is a visual element that occupies most or all of the screen and
contains a single child. A Xamarin.Forms.Page represents a View Controller in
iOS or a Page in Windows Phone. On Android each page takes up the screen like
an Activity, but Xamarin.Forms Pages are not Activities.
 ContentPage
A ContentPage displays a single View,often a container such as a StackLayout or a
ScrollView.
In the ContentPage class,there is a property named Content that can be assigned to
via code or by placing the child (content) UI element within ContentPage element.
XAML Example (Lab 1)
P a g e 7 | 17
XAMARIN.FORMS HANDS
 TabbedPage
A Page that allows navigation between children pages,using Tabs.
In Xamarin.Forms applications, a TabbedPage is generally useful when you have a
small predefined number of pages that users can navigate between, such as a menu
or a simple wizard that can be positioned at the top of bottom of the screen.
XAML Example (Lab 2)
P a g e 8 | 17
XAMARIN.FORMS HANDS
Layouts
Xamrin.Forms has several layouts and features for organizing content on screen.
Each Layout control is described below,as well as details on how to handle screen
orientation changes:
Choosing the Right Layout
The layouts you choose in your app can either help or hurt you as you're creating
an attractive and usable Xamarin.Forms app. Taking some time to consider how
each layout works can help you write cleaner and more scalable UI code. A screen
can have a combination of different layouts to achieve a specific design.
 Stack Layout
StackLayout – used to arrange views linearly, either horizontally or vertically.
Views in a StackLayout can be aligned to the center, left or right of the layout.
A StackLayout is used to automatically position all of its child elements in a single
line.The direction of the line is based on the Orientation property.The valid options
for this property are Horizontal or Vertical.The Default value,if not explicity set,is
Vertical.
When it comes to adjusting the amount of space between the child elements in the
StackLayout,this should be done using the Spacing property and not at the
individual child element level.During the layout process of a StackLayout,the user-
assigned bounds will be overwritten and set to the value associated with the
StackLayout control.
XAML Example (Lab 3)
P a g e 9 | 17
XAMARIN.FORMS HANDS
 Absolute Layout
AbsoluteLayout – used to arrange views by setting coordinates & size in terms of
absolute values or ratios. AbsoluteLayout can be used to layer views as well as
anchor them to the left, right or center.
The AbsoluteLayout control in Xamarin.forms allows you to specify where exactly
on the screen you want the child elements to appear,as well as their size and shape
(bounds). There are a few different ways to set the bounds of the child elements
based on the AbsoluteLayoutFlags enumeration that are used during this process.
The AbsoluteLayoutFlags enumeration contains the following values:
 All: All dimensions are proportional.
 HeightProportional: Height is proportional to the layout.
 None: No interpretation is done.
 PositionProportional: Combines XProportional and YProportional.
 SizeProportional: Combines WidthProportional and HeightProportional.
 WidthProportional: Width is proportional to the layout.
 XProportional: X property is proportional to the layout.
 YProportional: Y property is proportional to the layout.
P a g e 10 | 17
XAMARIN.FORMS HANDS
XAML Example (Lab 4)
P a g e 11 | 17
XAMARIN.FORMS HANDS
 Grid Layout
Grid – used to arrange views in a grid. Rows and columns can be specified in terms of
absolute values or ratios.
The Grid container is a very useful option if you are looking to divide your screen into
a series of rows and columns in which you can place child elements.The process of
working with a Grid starts with creating a number of RowDefinition and
ColumnDefinition objects.Onece have created these,you are free to assign child
elements into a cell based on its coordinates.Once an element is placed within a
cell,any layout propertied assigned to that element will be applied to it with respect to
the cell it occupies.
When it comes to defining the Height and Width values in the RowDefinition and
ColumnDefinition objects,you have three options.You can define an explicit value that
the row or column will try to honor based on the amount of space available on the
screen.You can choose to set the value to auto – this value will automatically size the
row or column based on the size of its contents. Finally,you can use the star value (*)
which will allow that row or column to take all remaining space that is not used by
anything else. The following example uses star sizing.
XAML Example (Lab 4)
P a g e 12 | 17
XAMARIN.FORMS HANDS
Views
Xamarin.Forms uses the word View to refer to visual objects such as buttons,labels
or text entry boxes – which may be more commonly known as controls of widgets.
 ActivityIndicator
A visual control used to indicate that something is ongoing. This control gives a
visual clue to the user that something is happening, without information about its
progress.
There are only two properties that are specific to the ActivityIndicator control:
 Color: Sets the color of the ActivityIndicator
 IsRunning: Sets whether or not the ActivityIndicator should be animated.
XAML Example (Lab 6)
P a g e 13 | 17
XAMARIN.FORMS HANDS
 DatePicker
A View that allows date picking. The visual representation of a DatePicker is very
similar to the one of Entry, except that a special control for picking a date appears
in place of a keyboard
There are a few properties that are important to understand when working with the
DatePicker control:
 Date: The date displayed on the DatePicker.
 Format: The Format of the date on the DatePicker.Uses the same format
strings associated with the DateTime.ToString(string format) method.
 Maximumdate: The highest selectable date of the DatePicker.
 MinimumDate: The lowest selectable date of the DatePicker.
There is only one event exposed for the DatePicker class:
 DateSelected: Fired when the Date property has changed
XAML Example (Lab 7)
P a g e 14 | 17
XAMARIN.FORMS HANDS
 Editor
A control that can edit multiple lines of text.
There are two important properties associated with the Editor:
 Text: The text that is in the Editor
 Keyboard: The specific type of keyboard to be used while entering text.
There are two events raised by the entry to which you can subscribe:
 Completed: fired when the user finalizes the entry by tapping the Return
key.
 TextChanged: Fired when the text within the Editor is changed.
XAML Example (Lab 8)
P a g e 15 | 17
XAMARIN.FORMS HANDS
 Picker
A View control for picking an element in a list. The visual representation of a
Picker is similar to a Entry, but a picker control appears in place of a keyboard.
For being a relatively sophisticated control,there are only three properties of
note:
 Items: The list of options for the user.
 SelectedIndex: The currently selected options index in the list.
 Title: The title for the Picker.
XAML Example (Lab 9)
P a g e 16 | 17
XAMARIN.FORMS HANDS
 Switch Cell (Lab 10)
A SwitchCell is a Cell that combines the capabilities of a Label and on-off switch.
A SwitchCell can be useful for turning on and off functionality, or even user
preferences or configuration options.
The properties of the SwitchCell are fairly straightforward:
 On: Determines whether or not the switch is in the on position.
 Text: The text displayed next to the switch.
There is only a single event associated with the SwitchCell:
 OnChanged: Fired when the switch has changed value.
XAML Example (Lab 10)
P a g e 17 | 17
XAMARIN.FORMS HANDS

More Related Content

PPSX
Learn CATIA V5 in 3DEXPERIENCE 2017x
Antonio Napolitano
 
DOCX
Creating a data report in visual basic 6
mrgulshansharma
 
PPT
A Lap Around Visual Studio 2010
Abram John Limpin
 
PPT
Visual basic ppt for tutorials computer
simran153
 
PPTX
Visual basic
KavithaAlagumalai
 
DOCX
Visual basic
Dharmik
 
PDF
Salesforce interview preparation toolkit formula and validation rules in sale...
Amit Sharma
 
PPTX
Computer homework
adarsh-kaul
 
Learn CATIA V5 in 3DEXPERIENCE 2017x
Antonio Napolitano
 
Creating a data report in visual basic 6
mrgulshansharma
 
A Lap Around Visual Studio 2010
Abram John Limpin
 
Visual basic ppt for tutorials computer
simran153
 
Visual basic
KavithaAlagumalai
 
Visual basic
Dharmik
 
Salesforce interview preparation toolkit formula and validation rules in sale...
Amit Sharma
 
Computer homework
adarsh-kaul
 

What's hot (6)

PPTX
Excel chapter-7
OpenCastLabs Consulting
 
PPT
AIA101.3.Access Reports And Forms
Dan D'Urso
 
PPTX
I Simply Excel
Eric Couch
 
PDF
SYSTEMS DESIGN / CAPSTONE PROJECT
Sanjay Saluth
 
PPTX
Learn VBA Training & Advance Excel Courses in Delhi
ibinstitute0
 
DOCX
Report painter in SAP
Rajeev Kumar
 
Excel chapter-7
OpenCastLabs Consulting
 
AIA101.3.Access Reports And Forms
Dan D'Urso
 
I Simply Excel
Eric Couch
 
SYSTEMS DESIGN / CAPSTONE PROJECT
Sanjay Saluth
 
Learn VBA Training & Advance Excel Courses in Delhi
ibinstitute0
 
Report painter in SAP
Rajeev Kumar
 
Ad

Similar to Xamarin.Forms Hands On Lab (Begineer) (20)

PDF
Windows phone 8 session 3
hitesh chothani
 
PPTX
Exploring Adobe Flex
senthil0809
 
PPT
Vb introduction.
sagaroceanic11
 
PPTX
Getting hands on with xaml and xamarin
Mitchell Muenster
 
PPTX
Xamarin Development
Alper Ebicoglu
 
PDF
Building Accessible Apps using NET MAUI.pdf
SivarajAmbat1
 
PPTX
Xamarin.Forms a different approach to cross platform natove mobile development
Dan Ardelean
 
PDF
770_0629.pdf dump for oracle cloud interface
lknam1982
 
PPTX
Windows 8 app bar and live tiles
Amr Abulnaga
 
PDF
Oracle ADF 11g Skinning Tutorial
Rakesh Gujjarlapudi
 
PPTX
Xamarin 101
Chester Hartin
 
PPTX
Cble assignment powerpoint activity for moodle 1
LK394
 
PPTX
WP7 HUB_Introducción a Silverlight
MICTT Palma
 
PPTX
Vb6.0 intro
JOSEPHINEA6
 
PDF
Oracle General ledger ivas
Ali Ibrahim
 
DOCX
Visual C# 2010
Ali Mattash
 
PDF
Frontend Interview Questions PDF By ScholarHat
Scholarhat
 
PDF
Xamarin forms from zero to hero
Charlin Agramonte
 
PPT
Test
guest25229c
 
PPTX
Sda 9
AmberMughal5
 
Windows phone 8 session 3
hitesh chothani
 
Exploring Adobe Flex
senthil0809
 
Vb introduction.
sagaroceanic11
 
Getting hands on with xaml and xamarin
Mitchell Muenster
 
Xamarin Development
Alper Ebicoglu
 
Building Accessible Apps using NET MAUI.pdf
SivarajAmbat1
 
Xamarin.Forms a different approach to cross platform natove mobile development
Dan Ardelean
 
770_0629.pdf dump for oracle cloud interface
lknam1982
 
Windows 8 app bar and live tiles
Amr Abulnaga
 
Oracle ADF 11g Skinning Tutorial
Rakesh Gujjarlapudi
 
Xamarin 101
Chester Hartin
 
Cble assignment powerpoint activity for moodle 1
LK394
 
WP7 HUB_Introducción a Silverlight
MICTT Palma
 
Vb6.0 intro
JOSEPHINEA6
 
Oracle General ledger ivas
Ali Ibrahim
 
Visual C# 2010
Ali Mattash
 
Frontend Interview Questions PDF By ScholarHat
Scholarhat
 
Xamarin forms from zero to hero
Charlin Agramonte
 
Ad

More from Cheah Eng Soon (20)

PPTX
Microsoft Defender for Endpoint
Cheah Eng Soon
 
PPTX
Azure Active Directory - Secure and Govern
Cheah Eng Soon
 
PPTX
Microsoft Zero Trust
Cheah Eng Soon
 
PPTX
MEM for OnPrem Environments
Cheah Eng Soon
 
PPTX
Microsoft Threat Protection Automated Incident Response
Cheah Eng Soon
 
PDF
Azure Penetration Testing
Cheah Eng Soon
 
PDF
Azure Penetration Testing
Cheah Eng Soon
 
PPTX
Microsoft Threat Protection Automated Incident Response Demo
Cheah Eng Soon
 
PPTX
Microsoft Secure Score Demo
Cheah Eng Soon
 
PPTX
Microsoft Cloud App Security Demo
Cheah Eng Soon
 
PPTX
M365 Attack Simulation Demo
Cheah Eng Soon
 
PPTX
Cloud Security Demo
Cheah Eng Soon
 
PPTX
Azure Active Directory - External Identities Demo
Cheah Eng Soon
 
PPTX
Azure WAF
Cheah Eng Soon
 
PPTX
Azure Weekend 2020 Build Malaysia Bus Uncle Chatbot
Cheah Eng Soon
 
PPTX
Microsoft Azure的20大常见安全漏洞与配置错误
Cheah Eng Soon
 
PDF
20 common security vulnerabilities and misconfiguration in Azure
Cheah Eng Soon
 
PPTX
Integrate Microsoft Graph with Azure Bot Services
Cheah Eng Soon
 
PPTX
Azure Sentinel with Office 365
Cheah Eng Soon
 
PPTX
3 Steps Integrate Microsoft Graph with Azure Bot Services
Cheah Eng Soon
 
Microsoft Defender for Endpoint
Cheah Eng Soon
 
Azure Active Directory - Secure and Govern
Cheah Eng Soon
 
Microsoft Zero Trust
Cheah Eng Soon
 
MEM for OnPrem Environments
Cheah Eng Soon
 
Microsoft Threat Protection Automated Incident Response
Cheah Eng Soon
 
Azure Penetration Testing
Cheah Eng Soon
 
Azure Penetration Testing
Cheah Eng Soon
 
Microsoft Threat Protection Automated Incident Response Demo
Cheah Eng Soon
 
Microsoft Secure Score Demo
Cheah Eng Soon
 
Microsoft Cloud App Security Demo
Cheah Eng Soon
 
M365 Attack Simulation Demo
Cheah Eng Soon
 
Cloud Security Demo
Cheah Eng Soon
 
Azure Active Directory - External Identities Demo
Cheah Eng Soon
 
Azure WAF
Cheah Eng Soon
 
Azure Weekend 2020 Build Malaysia Bus Uncle Chatbot
Cheah Eng Soon
 
Microsoft Azure的20大常见安全漏洞与配置错误
Cheah Eng Soon
 
20 common security vulnerabilities and misconfiguration in Azure
Cheah Eng Soon
 
Integrate Microsoft Graph with Azure Bot Services
Cheah Eng Soon
 
Azure Sentinel with Office 365
Cheah Eng Soon
 
3 Steps Integrate Microsoft Graph with Azure Bot Services
Cheah Eng Soon
 

Recently uploaded (20)

PDF
Structs to JSON: How Go Powers REST APIs
Emily Achieng
 
PDF
Brief History of Internet - Early Days of Internet
sutharharshit158
 
PPTX
OA presentation.pptx OA presentation.pptx
pateldhruv002338
 
PPTX
IT Runs Better with ThousandEyes AI-driven Assurance
ThousandEyes
 
PDF
Security features in Dell, HP, and Lenovo PC systems: A research-based compar...
Principled Technologies
 
PDF
Research-Fundamentals-and-Topic-Development.pdf
ayesha butalia
 
PDF
Get More from Fiori Automation - What’s New, What Works, and What’s Next.pdf
Precisely
 
PPTX
cloud computing vai.pptx for the project
vaibhavdobariyal79
 
PDF
Orbitly Pitch Deck|A Mission-Driven Platform for Side Project Collaboration (...
zz41354899
 
PDF
The Future of Artificial Intelligence (AI)
Mukul
 
PDF
The Evolution of KM Roles (Presented at Knowledge Summit Dublin 2025)
Enterprise Knowledge
 
PPTX
AI in Daily Life: How Artificial Intelligence Helps Us Every Day
vanshrpatil7
 
PDF
BLW VOCATIONAL TRAINING SUMMER INTERNSHIP REPORT
codernjn73
 
PDF
A Day in the Life of Location Data - Turning Where into How.pdf
Precisely
 
PDF
Automating ArcGIS Content Discovery with FME: A Real World Use Case
Safe Software
 
PDF
Cloud-Migration-Best-Practices-A-Practical-Guide-to-AWS-Azure-and-Google-Clou...
Artjoker Software Development Company
 
PDF
Using Anchore and DefectDojo to Stand Up Your DevSecOps Function
Anchore
 
PDF
How Open Source Changed My Career by abdelrahman ismail
a0m0rajab1
 
PDF
Advances in Ultra High Voltage (UHV) Transmission and Distribution Systems.pdf
Nabajyoti Banik
 
PDF
Responsible AI and AI Ethics - By Sylvester Ebhonu
Sylvester Ebhonu
 
Structs to JSON: How Go Powers REST APIs
Emily Achieng
 
Brief History of Internet - Early Days of Internet
sutharharshit158
 
OA presentation.pptx OA presentation.pptx
pateldhruv002338
 
IT Runs Better with ThousandEyes AI-driven Assurance
ThousandEyes
 
Security features in Dell, HP, and Lenovo PC systems: A research-based compar...
Principled Technologies
 
Research-Fundamentals-and-Topic-Development.pdf
ayesha butalia
 
Get More from Fiori Automation - What’s New, What Works, and What’s Next.pdf
Precisely
 
cloud computing vai.pptx for the project
vaibhavdobariyal79
 
Orbitly Pitch Deck|A Mission-Driven Platform for Side Project Collaboration (...
zz41354899
 
The Future of Artificial Intelligence (AI)
Mukul
 
The Evolution of KM Roles (Presented at Knowledge Summit Dublin 2025)
Enterprise Knowledge
 
AI in Daily Life: How Artificial Intelligence Helps Us Every Day
vanshrpatil7
 
BLW VOCATIONAL TRAINING SUMMER INTERNSHIP REPORT
codernjn73
 
A Day in the Life of Location Data - Turning Where into How.pdf
Precisely
 
Automating ArcGIS Content Discovery with FME: A Real World Use Case
Safe Software
 
Cloud-Migration-Best-Practices-A-Practical-Guide-to-AWS-Azure-and-Google-Clou...
Artjoker Software Development Company
 
Using Anchore and DefectDojo to Stand Up Your DevSecOps Function
Anchore
 
How Open Source Changed My Career by abdelrahman ismail
a0m0rajab1
 
Advances in Ultra High Voltage (UHV) Transmission and Distribution Systems.pdf
Nabajyoti Banik
 
Responsible AI and AI Ethics - By Sylvester Ebhonu
Sylvester Ebhonu
 

Xamarin.Forms Hands On Lab (Begineer)

  • 1. Xamarin.Forms Hands On Lab 2016 PREPARED BY ENG SOON CHEAH , MICROSOFT MVP ENG SOON CHEAH XAMARIN MALAYSIA DEVELOPERS
  • 2. P a g e 1 | 17 XAMARIN.FORMS HANDS Chapter 1 : Create your first Xamarin.Forms Application Chapter 2 : Pages  ContentPage (Lab 1)  TabbedPage (Lab 2) Chapter 3 : Layouts  StackLayout (Lab 3)  AbsoluteLayout (Lab 4)  Grid (Lab 5) Chapter 4 : Views  ActivityIndicator (Lab 6)  DatePicker (Lab 7)  Editor (Lab 8)  Picker (Lab 9)  Switch Cell (Lab 10) Chapter 5 : Tutorial
  • 3. P a g e 2 | 17 XAMARIN.FORMS HANDS CHAPTER 1: Create Your First Xamarin.Forms Application In the Start screen, launch Visual Studio. This opens the start page: 2. In Visual Studio, click New Project... to create a new project:
  • 4. P a g e 3 | 17 XAMARIN.FORMS HANDS 3. In the New Project dialog, click Mobile Apps, select the Blank App (Xamarin.Forms Portable) template, set the Name and Solution name to Phoneword, choose a suitable location for the project and then click the OK button: 4. In Solution Explorer, right click on the Phoneword project and select Add > New Item...
  • 5. P a g e 4 | 17 XAMARIN.FORMS HANDS 5. In the Add New Item dialog, select Visual C# > Forms Xaml Page, name the new file MainPage, and click the Add button. This will add a page named MainPage to the project: When it comes to sharing code within Xamarin.Forms applications,you have two primarily accepted methods:  Portable Class Libraries  Shared Projects Xamarin.Forms and PCLs Just like any choice you are faced with in software development,there are always pros and cons to take into consideration. Using PCLs within your Xamarin.Forms application is no different. While PCLs work very well in Xamarin.Forms applications,there are a few very important things to consider when choosing them in your projects: Pros:  Can access other PCLs targeting similar frameworks.  Allow you to use XAML-based views
  • 6. P a g e 5 | 17 XAMARIN.FORMS HANDS  Easy to write unit tests to verify functionality.  Generate an assembly that can be shared in other projects. Cons:  Can’t contain platform-specific code.  Can’t reference any projects or libraries that contain platform-specific code.  Only contain access to a subset of the .NET Framework. Xamarin.Forms and Shared Projects Choosing to use Shared Projects with your Xamarin.Forms application can provide you with further opportunities to consolidate shared code used by your application. This further consolidation comes at a bit of a cost,but depending on the type of application you are building,this cost may be acceptable. In order to make and educated decision about whether or not you should use Shared Projects,consider their pros and cons: Pros  Have access to all functionality in referencing projects.  Can contain platform-specific code.  Support conditional compilation to allow multiple platform-specific code in a single file. Cons  Doesn’t create an assembly, so code can’t be shared to other applications.  Doesn’t support creating views using XAML.  Unit testing is more complicated when platform-specific code exits.
  • 7. P a g e 6 | 17 XAMARIN.FORMS HANDS Pages The Page class is a visual element that occupies most or all of the screen and contains a single child. A Xamarin.Forms.Page represents a View Controller in iOS or a Page in Windows Phone. On Android each page takes up the screen like an Activity, but Xamarin.Forms Pages are not Activities.  ContentPage A ContentPage displays a single View,often a container such as a StackLayout or a ScrollView. In the ContentPage class,there is a property named Content that can be assigned to via code or by placing the child (content) UI element within ContentPage element. XAML Example (Lab 1)
  • 8. P a g e 7 | 17 XAMARIN.FORMS HANDS  TabbedPage A Page that allows navigation between children pages,using Tabs. In Xamarin.Forms applications, a TabbedPage is generally useful when you have a small predefined number of pages that users can navigate between, such as a menu or a simple wizard that can be positioned at the top of bottom of the screen. XAML Example (Lab 2)
  • 9. P a g e 8 | 17 XAMARIN.FORMS HANDS Layouts Xamrin.Forms has several layouts and features for organizing content on screen. Each Layout control is described below,as well as details on how to handle screen orientation changes: Choosing the Right Layout The layouts you choose in your app can either help or hurt you as you're creating an attractive and usable Xamarin.Forms app. Taking some time to consider how each layout works can help you write cleaner and more scalable UI code. A screen can have a combination of different layouts to achieve a specific design.  Stack Layout StackLayout – used to arrange views linearly, either horizontally or vertically. Views in a StackLayout can be aligned to the center, left or right of the layout. A StackLayout is used to automatically position all of its child elements in a single line.The direction of the line is based on the Orientation property.The valid options for this property are Horizontal or Vertical.The Default value,if not explicity set,is Vertical. When it comes to adjusting the amount of space between the child elements in the StackLayout,this should be done using the Spacing property and not at the individual child element level.During the layout process of a StackLayout,the user- assigned bounds will be overwritten and set to the value associated with the StackLayout control. XAML Example (Lab 3)
  • 10. P a g e 9 | 17 XAMARIN.FORMS HANDS  Absolute Layout AbsoluteLayout – used to arrange views by setting coordinates & size in terms of absolute values or ratios. AbsoluteLayout can be used to layer views as well as anchor them to the left, right or center. The AbsoluteLayout control in Xamarin.forms allows you to specify where exactly on the screen you want the child elements to appear,as well as their size and shape (bounds). There are a few different ways to set the bounds of the child elements based on the AbsoluteLayoutFlags enumeration that are used during this process. The AbsoluteLayoutFlags enumeration contains the following values:  All: All dimensions are proportional.  HeightProportional: Height is proportional to the layout.  None: No interpretation is done.  PositionProportional: Combines XProportional and YProportional.  SizeProportional: Combines WidthProportional and HeightProportional.  WidthProportional: Width is proportional to the layout.  XProportional: X property is proportional to the layout.  YProportional: Y property is proportional to the layout.
  • 11. P a g e 10 | 17 XAMARIN.FORMS HANDS XAML Example (Lab 4)
  • 12. P a g e 11 | 17 XAMARIN.FORMS HANDS  Grid Layout Grid – used to arrange views in a grid. Rows and columns can be specified in terms of absolute values or ratios. The Grid container is a very useful option if you are looking to divide your screen into a series of rows and columns in which you can place child elements.The process of working with a Grid starts with creating a number of RowDefinition and ColumnDefinition objects.Onece have created these,you are free to assign child elements into a cell based on its coordinates.Once an element is placed within a cell,any layout propertied assigned to that element will be applied to it with respect to the cell it occupies. When it comes to defining the Height and Width values in the RowDefinition and ColumnDefinition objects,you have three options.You can define an explicit value that the row or column will try to honor based on the amount of space available on the screen.You can choose to set the value to auto – this value will automatically size the row or column based on the size of its contents. Finally,you can use the star value (*) which will allow that row or column to take all remaining space that is not used by anything else. The following example uses star sizing. XAML Example (Lab 4)
  • 13. P a g e 12 | 17 XAMARIN.FORMS HANDS Views Xamarin.Forms uses the word View to refer to visual objects such as buttons,labels or text entry boxes – which may be more commonly known as controls of widgets.  ActivityIndicator A visual control used to indicate that something is ongoing. This control gives a visual clue to the user that something is happening, without information about its progress. There are only two properties that are specific to the ActivityIndicator control:  Color: Sets the color of the ActivityIndicator  IsRunning: Sets whether or not the ActivityIndicator should be animated. XAML Example (Lab 6)
  • 14. P a g e 13 | 17 XAMARIN.FORMS HANDS  DatePicker A View that allows date picking. The visual representation of a DatePicker is very similar to the one of Entry, except that a special control for picking a date appears in place of a keyboard There are a few properties that are important to understand when working with the DatePicker control:  Date: The date displayed on the DatePicker.  Format: The Format of the date on the DatePicker.Uses the same format strings associated with the DateTime.ToString(string format) method.  Maximumdate: The highest selectable date of the DatePicker.  MinimumDate: The lowest selectable date of the DatePicker. There is only one event exposed for the DatePicker class:  DateSelected: Fired when the Date property has changed XAML Example (Lab 7)
  • 15. P a g e 14 | 17 XAMARIN.FORMS HANDS  Editor A control that can edit multiple lines of text. There are two important properties associated with the Editor:  Text: The text that is in the Editor  Keyboard: The specific type of keyboard to be used while entering text. There are two events raised by the entry to which you can subscribe:  Completed: fired when the user finalizes the entry by tapping the Return key.  TextChanged: Fired when the text within the Editor is changed. XAML Example (Lab 8)
  • 16. P a g e 15 | 17 XAMARIN.FORMS HANDS  Picker A View control for picking an element in a list. The visual representation of a Picker is similar to a Entry, but a picker control appears in place of a keyboard. For being a relatively sophisticated control,there are only three properties of note:  Items: The list of options for the user.  SelectedIndex: The currently selected options index in the list.  Title: The title for the Picker. XAML Example (Lab 9)
  • 17. P a g e 16 | 17 XAMARIN.FORMS HANDS  Switch Cell (Lab 10) A SwitchCell is a Cell that combines the capabilities of a Label and on-off switch. A SwitchCell can be useful for turning on and off functionality, or even user preferences or configuration options. The properties of the SwitchCell are fairly straightforward:  On: Determines whether or not the switch is in the on position.  Text: The text displayed next to the switch. There is only a single event associated with the SwitchCell:  OnChanged: Fired when the switch has changed value. XAML Example (Lab 10)
  • 18. P a g e 17 | 17 XAMARIN.FORMS HANDS