Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecture 3 Multiple Pages.

Similar presentations


Presentation on theme: "Lecture 3 Multiple Pages."— Presentation transcript:

1 Lecture 3 Multiple Pages

2 MainPage = new GreetingsPage(); }
In the previous App we set MainPage to a member of the GreetingsPage class. If we wish to display multiple pages in our App we can set public App() { MainPage = new GreetingsPage(); } public App() { // The root page of your application MainPage = new NavigationPage(new ButtonPage()); }

3 Create two or more content page classes….
e.g. buttonPage and another Page as shown here

4 1. Right-Click Project 2. Select Add -> New Item…

5 3. Choose Visual C# -> Cross-Platform
4. Highlight Forms ContentPage 5. Name this content Page class 6. Add to Project

6 using System; using Xamarin.Forms; namespace NowApp { public class anotherPage : ContentPage Label label1 = new Label Text = "This is Another Page", FontSize = 30, FontAttributes = FontAttributes.Bold, HorizontalOptions = LayoutOptions.Center }; public anotherPage() Content = new StackLayout Children = label1 }

7 public class ButtonPage : ContentPage public ButtonPage()
using System; using Xamarin.Forms; namespace NowApp { public class ButtonPage : ContentPage public ButtonPage() Button button = new Button Text = "Now", BorderWidth = 1, HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.CenterAndExpand }; button.Clicked += OnButtonClicked; this.Padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 5); this.Content = new StackLayout Children = button } void OnButtonClicked(object sender, EventArgs e) Navigation.PushAsync(new anotherPage()); PushAsync permits the use of “back” to return to the Previous page… What are the alternatives to PushAsync?

8

9

10


Download ppt "Lecture 3 Multiple Pages."

Similar presentations


Ads by Google