Ejemplo n.º 1
0
        protected override void Init()
        {
            var cells = new [] {
                new NavPageNameObject("Close Master"),
                new NavPageNameObject("Page 1"),
                new NavPageNameObject("Page 3"),
                new NavPageNameObject("Page 4"),
                new NavPageNameObject("Page 5"),
                new NavPageNameObject("Page 6"),
                new NavPageNameObject("Page 7"),
                new NavPageNameObject("Page 8"),
            };

            var template = new DataTemplate(typeof(TextCell));

            template.SetBinding(TextCell.TextProperty, "PageName");

            var listView = new ListView {
                ItemTemplate = template,
                ItemsSource  = cells
            };

            listView.BindingContext = cells;

            listView.ItemTapped += (sender, e) => {
                var cellName = ((NavPageNameObject)e.Item).PageName;
                if (cellName == "Close Master")
                {
                    IsPresented = false;
                }
                else
                {
                    Detail = new CustomNavDetailPage(cellName);
                }
            };

            var master = new ContentPage {
                Padding = new Thickness(0, 20, 0, 0),
                Title   = "Master",
                Content = listView
            };

            Master = master;
            Detail = new CustomNavDetailPage("Initial Page");

            MessagingCenter.Subscribe <NestedNavPageRootView> (this, "PresentMaster", (sender) => {
                IsPresented = true;
            });
        }
Ejemplo n.º 2
0
		protected override void Init ()
		{
			var cells = new [] {
				new NavPageNameObject ("Close Master"),
				new NavPageNameObject ("Page 1"),
				new NavPageNameObject ("Page 3"),
				new NavPageNameObject ("Page 4"),
				new NavPageNameObject ("Page 5"),
				new NavPageNameObject ("Page 6"),
				new NavPageNameObject ("Page 7"),
				new NavPageNameObject ("Page 8"),
			};

			var template = new DataTemplate (typeof (TextCell));
			template.SetBinding (TextCell.TextProperty, "PageName");

			var listView = new ListView { 
				ItemTemplate = template,
				ItemsSource = cells
			};

			listView.BindingContext = cells;

			listView.ItemTapped += (sender, e) => {
				var cellName = ((NavPageNameObject)e.Item).PageName;
				if (cellName == "Close Master") {
					IsPresented = false;
				} else {
					Detail = new CustomNavDetailPage (cellName);
				}
			};

			var master = new ContentPage {
				Padding = new Thickness(0, 20, 0, 0),
				Title = "Master",
				Content = listView
			};
				
			Master = master;
			Detail = new CustomNavDetailPage ("Initial Page");

			MessagingCenter.Subscribe<NestedNavPageRootView> (this, "PresentMaster", (sender) => {
				IsPresented = true;
			});
		}