Slide 1

Slide 1 text

Navigation In Xamarin.Forms Kym Phillpotts [email protected] @kphillpotts
 
 code & slides: 
 https://github.com/kphillpotts/XFNavigation

Slide 2

Slide 2 text

Topics Xamarin.Forms Overview •  Where does Xamarin.Forms fit in? •  What does the XF framework give you?
 Navigation in Xamarin.Forms •  Push, Pop and Modal •  Lists Navigation •  Tabbed Pages •  Master / Detail Pages •  Carousel Pages
 Additional Resources •  Design Resources •  Xamarin Resources

Slide 3

Slide 3 text

Xamarin.Forms
 Overview

Slide 4

Slide 4 text

Traditional Xamarin Approach Android (Platform Specific C#) iOS (Platform Specific C#) Windows (Platform Specific C#) Shared C# Backend (Typically PCL or Shared libraries)

Slide 5

Slide 5 text

Shared C# Backend (Typically PCL or Shared libraries) Shared User Interface Code Xamarin Forms - C# or XAML Xamarin Forms Approach

Slide 6

Slide 6 text

How Xamarin.Forms Renders Controls Button  button  =  new  Button  {        Text  =  "Click  Me!"     };   UI uses a Xamarin.Forms Button Platform Renderer takes view and turns it into platform-specific control Android.Widget.Button   UIButton   System.Windows.Button  

Slide 7

Slide 7 text

What’s in the box? •  Pages Content Page Master Detail NavigationPage TabbedPage CarouselPage

Slide 8

Slide 8 text

What’s in the box? •  Pages •  Layouts StackLayout AbsoluteLayout RelativeLayout GridLayout ContentView ScrollView Frame

Slide 9

Slide 9 text

What’s in the box? •  Pages •  Layouts •  Controls ActivityIndicator Entry BoxView Image Button Label DatePicker ListView Editor Map OpenGLView Stepper Picker TableView ProgressBar TimePicker SearchBar WebView Slider EntryCell ImageCell SwitchCell TextCell ViewCell

Slide 10

Slide 10 text

Topics Xamarin.Forms Overview •  Where does Xamarin.Forms fit in? •  What does the XF framework give you?
 Navigation in Xamarin.Forms •  NavigationPage •  Lists Navigation •  Tabbed Pages •  Carousel Pages •  Master / Detail Pages
 Additional Resources •  Design Resources •  Xamarin Resources

Slide 11

Slide 11 text

NavigationPage

Slide 12

Slide 12 text

Navigation Page Basic Concepts •  Push pages onto the stack •  Pop pages off the stack Hierarchical Navigation •  PushAsync() •  PopAsync() •  PopToRootAsync() Modal Navigation •  PushModalAsync() •  PopModalAsync()

Slide 13

Slide 13 text

Implementing NavigationPage – Wrap it! ! ! public App()! {! MainPage = new MyPage();! } ! !

Slide 14

Slide 14 text

Implementing NavigationPage – Wrap it! ! ! public App()! {! // MainPage = new MyPage();! MainPage = new NavigationPage(new MyPage());! } ! !

Slide 15

Slide 15 text

Hierarchical Navigation Navigate Forward (Push) Navigation.PushAsync(new SecondPage());! ! Navigate Back One Page (Pop) Navigation.PopAsync();! ! Navigate Back To First Page (PopToRoot) Navigation.PopToRoot();! !

Slide 16

Slide 16 text

Modal Navigation Display A Modal Page Navigation.PushModalAsync(new MyNewModalPage());! ! Remove A Modal Page Navigation.PopModalAsync();! !

Slide 17

Slide 17 text

GUIDELINES – DO NOT USE SLIDE

Slide 18

Slide 18 text

Other NavigationPage Goodness ■  Have access to the NavigationStack -  InsertPage -  RemovePage ■  BackButtonPressed Events ■  Customizing the navigation bar -  var navPage = new NavigationPage(new MyPage()); -  navPage.BarBackgroundColor = Color.Green; -  navPage.BarTextColor = Color.White; ■  NavigationBar Icons -  NavigationPage.SetTitleIcon(this, “your-logo-here.png");

Slide 19

Slide 19 text

ListView Navigation

Slide 20

Slide 20 text

Using ListViews for Navigation ■  Make sure you wrap your ListView page inside a NavigationPage ■  Setup your listview data and bindings (as per normal) ■  Respond to the ItemTapped Event (as per normal) ■  Use the NavigationPage methods to Push to new pages

Slide 21

Slide 21 text

GUIDELINES – DO NOT USE SLIDE

Slide 22

Slide 22 text

Other ListView goodness you should check out ■  Pull To Refresh ■  Action Buttons ■  Search Bar ■  Circle Images – Plugin ■  Grouped Lists – James Montemagno -  http://bit.ly/GroupedListView

Slide 23

Slide 23 text

TabbedPage

Slide 24

Slide 24 text

TabbedPage Basic Concepts •  Creates a tabbed interface for a collection of child pages Platform Differences •  On iOS Tabs at bottom with icon •  On Android tabs at the top without icon •  On Windows Phone uses Pivot control

Slide 25

Slide 25 text

No content

Slide 26

Slide 26 text

Implementing TabbedPage Adding pages to the TabbedPage
 
 public class TabsPage : TabbedPage! {! public TabsPage ()! {! this.Children.Add (new Page1 () { Title = “Page1", Icon = “Page1.png" });! this.Children.Add (new Page2 () { Title = “Page2",Icon = “Page2.png" });! this.Children.Add (new Page3 () { Title = “Page3", Icon = “Page3.png" });! this.Children.Add (new Page4 () { Title = “Page4", Icon = “Page4.png" });! }! }! !

Slide 27

Slide 27 text

Navigation inside a TabbedPage It’s easy, just wrap your children in a NavigationPage
 
 Children.Add ( new NavigationPage (new ChildPage()) ! {! Title = “PageName", ! Icon = “PageIcon.png" ! });! !

Slide 28

Slide 28 text

No content

Slide 29

Slide 29 text

CarouselPage

Slide 30

Slide 30 text

No content

Slide 31

Slide 31 text

Implementing CarouselPage Adding pages to the CarouselPage
 
 public class FlippyPage : TabbedPage! {! public FlippyPage ()! {! Children.Add(new BucketItemDetail(buckteItem));! Children.Add(new BucketItemDetail(buckteItem));! Children.Add(new BucketItemDetail(buckteItem));! }! }! !

Slide 32

Slide 32 text

No content

Slide 33

Slide 33 text

MasterDetailPage

Slide 34

Slide 34 text

MasterDetailPage Basic Concepts •  A container page that manages the 
 presentation of two other pages.
 •  A master page, which typically shows a list 
 or menu of options
 •  A detail page, which typically shows the detail of the selection

Slide 35

Slide 35 text

Implementing the MasterDetailPage public class SimpleMasterDetailContainer : MasterDetailPage { public SimpleMasterDetailContainer() { Master = new SimpleMasterPage(); Detail = new NavigationPage(new SimpleDetailPage()); } }

Slide 36

Slide 36 text

Things to Remember with MasterDetailPage You have to provide a Title in the Master Page, or things go bang! (optionally you can add an Icon to display – think hamburger icon) You have to handle the navigation between the master and the details pages. Do this by setting Detail property
 For Tablets you can use MasterBehavior property •  Default •  PopOver •  SplitOnHorizontal •  SplitOnVertical

Slide 37

Slide 37 text

No content

Slide 38

Slide 38 text

Topics Xamarin.Forms Overview •  Where does Xamarin.Forms fit in? •  What does the XF framework give you?
 Navigation in Xamarin.Forms •  Push, Pop and Modal •  Lists Navigation •  Tabbed Pages •  Master / Detail Pages •  Carousel Pages
 Additional Resources •  Design Resources •  Xamarin Resources

Slide 39

Slide 39 text

Design Resources •  Xamarin.Forms in Anger – Replicating designs in Xamarin.Forms
 https://www.syntaxismyui.com/xamarin-forms-in-anger
 •  Dribbble – Awesome ideas by bizarrely talented artists
 http://dribbble.com
 •  UI-Patterns – They why & why nots of UI
 http://ui-patterns.com 


Slide 40

Slide 40 text

Xamarin.Forms Dev Resources •  Xamarin Community blog – Aggregates the best Xamarin blogs
 http://planet.xamarin.com/ 
 •  Official Xamarin.Forms Website – Links to all the official doco & samples
 http://xamarin.com/forms •  Xamarin-Forms-Labs – Community controls and code
 https://github.com/XLabs/Xamarin-Forms-Labs •  Xamarin Plugins – Awesome nuget plugins that work with Xamarin.Forms •  https://github.com/xamarin/plugins •  Free Charles Petzold Xamarin Forms eBook 
 http://bit.ly/PetzoldBook
 
 


Slide 41

Slide 41 text

THANKS (and questions) Kym Phillpotts [email protected] @kphillpotts
 
 code & slides: 
 https://github.com/kphillpotts/XFNavigation