summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Controls/GalleryPages/ToolbarGallery.cs
blob: b2be5f020cf45db862602a893d42e63f2f6d4758 (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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Xamarin.Forms.Controls
{
	public class ToolbarGallery : ContentPage
	{
		readonly Toolbar _toolbar;
		readonly StackLayout _stack;

		public ToolbarGallery ()
		{
			var label = new Label {
				Text = "Click the toolbar"
			};

			Content = _stack = new StackLayout ();
			_stack.Children.Add (label);

			foreach (string name in new[] { "One", "Two", "Three", "Four" }) {
				var toolbarItem = new ToolbarItem (name, null, delegate {
					label.Text = "Activated: " + name;
				}, ToolbarItemOrder.Secondary);
				ToolbarItems.Add (toolbarItem);
			}

			var imagePrimaryItem = new ToolbarItem (null, "menuIcon.png", () => label.Text = "Activated: Primary Image 1", ToolbarItemOrder.Primary);
			var imagePrimaryItemWithTitle = new ToolbarItem ("Primary", "menuIcon.png", () => label.Text = "Activated: Primary Image 2", ToolbarItemOrder.Primary);
			var imageItem = new ToolbarItem (null, "seth.png", () => label.Text = "Activated: Secondary Image 1", ToolbarItemOrder.Secondary);
			var imageItemWithTitle = new ToolbarItem ("Secondary", "seth.png", () => label.Text = "Activated: Secondary Image 2", ToolbarItemOrder.Secondary);
			ToolbarItems.Add (imagePrimaryItem);
			ToolbarItems.Add (imagePrimaryItemWithTitle);
			ToolbarItems.Add (imageItem);
			ToolbarItems.Add (imageItemWithTitle);
		}
	}
}