summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Controls/GalleryPages/NavigationPropertiesGallery.cs
blob: 0628cfa8e103953dffc00d63016953dcad01b257 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Xamarin.Forms.Controls
{
	public class NavigationPropertiesGallery
		: ContentPage
	{
		public NavigationPropertiesGallery ()
		{
			var noBack = new ContentPage {
				Title = "No back button",
			};
			NavigationPage.SetHasBackButton (noBack, false);
			var toggleBackButton = new Button { Text = "Toggle Back Button" };
			toggleBackButton.Clicked += (sender, e) => {
				var hasBack = NavigationPage.GetHasBackButton (noBack);
				if (hasBack)
					NavigationPage.SetHasBackButton (noBack, false);
				else
					NavigationPage.SetHasBackButton (noBack, true);
			};
			noBack.Content = toggleBackButton;


			var noBar = new ContentPage {
				Title = "No bar",
				Content = new Label {
					Text = "No bar content",
					Style = Device.Styles.TitleStyle
				}
			};

			var backTitle = new ContentPage {
				Title = "Back button title"
			};

			NavigationPage.SetHasNavigationBar (noBar, false);

			Content = new ListView {
				ItemsSource = new[] {
					noBack,
					noBar,
					backTitle
				},

				ItemTemplate = new DataTemplate (typeof(TextCell)) {
					Bindings = {
						{ TextCell.TextProperty, new Binding ("Title") }
					}
				}
			};

			((ListView) Content).ItemTapped += async (sender, args) => {
				await Navigation.PushAsync ((Page) args.Item);
			};

			NavigationPage.SetBackButtonTitle (this, "Back Title");
		}
	}
}