예제 #1
0
        public HomeMasterView(HomeViewModel viewModel)
        {
            this.Icon      = "slideout.png";
            BindingContext = viewModel;


            var layout = new StackLayout {
                Spacing = 0
            };

            var label = new ContentView {
                Padding         = new Thickness(10, 36, 0, 5),
                BackgroundColor = Color.Transparent,
                Content         = new Label {
                    Text = "MENU",
                    Font = Font.SystemFontOfSize(NamedSize.Medium)
                }
            };

            layout.Children.Add(label);

            var listView = new ListView();

            var cell = new DataTemplate(typeof(ListImageCell));

            cell.SetBinding(TextCell.TextProperty, HomeViewModel.TitlePropertyName);
            cell.SetBinding(ImageCell.ImageSourceProperty, "Icon");

            listView.ItemTemplate = cell;

            listView.ItemsSource = viewModel.MenuItems;
            if (about == null)
            {
                about = new AboutView();
            }

            PageSelection = about;
            //Change to the correct page
            listView.ItemSelected += (sender, args) =>
            {
                var menuItem = listView.SelectedItem as HomeMenuItem;
                menuType = menuItem.MenuType;
                switch (menuItem.MenuType)
                {
                case MenuType.About:
                    if (about == null)
                    {
                        about = new AboutView();
                    }

                    PageSelection = about;
                    break;

                case MenuType.Blog:
                    if (blog == null)
                    {
                        blog = new BlogView();
                    }

                    PageSelection = blog;
                    break;

                case MenuType.Twitter:
                    if (twitter == null)
                    {
                        twitter = new TwitterView();
                    }

                    PageSelection = twitter;
                    break;
                }
            };

            listView.SelectedItem = viewModel.MenuItems[0];
            layout.Children.Add(listView);

            Content = layout;
        }
예제 #2
0
		public HomeMasterView(HomeViewModel viewModel)
		{
			this.Icon = "slideout.png";
			BindingContext = viewModel;

      
			var layout = new StackLayout { Spacing = 0 };

			var label = new ContentView {
				Padding = new Thickness(10, 36, 0, 5),
				BackgroundColor = Color.Transparent,
				Content = new Label {
					Text = "MENU",
					Font = Font.SystemFontOfSize (NamedSize.Medium)
				}
			};

			layout.Children.Add(label);
		
			var listView = new ListView ();

			var cell = new DataTemplate(typeof(ListImageCell));

			cell.SetBinding (TextCell.TextProperty, HomeViewModel.TitlePropertyName);
			cell.SetBinding (ImageCell.ImageSourceProperty, "Icon");

			listView.ItemTemplate = cell;

			listView.ItemsSource = viewModel.MenuItems;
			if (about == null)
				about = new AboutView ();

			PageSelection = about;
			//Change to the correct page
			listView.ItemSelected += (sender, args) =>
			{
				var menuItem = listView.SelectedItem as HomeMenuItem;
				menuType = menuItem.MenuType;
				switch(menuItem.MenuType){
				case MenuType.About:
					if(about == null)
						about = new AboutView();

					PageSelection = about;
					break;
				case MenuType.Blog:
					if(blog == null)
						blog = new BlogView();
						
					PageSelection = blog;
					break;
				case MenuType.Twitter:
					if(twitter == null)
						twitter = new TwitterView();

					PageSelection = twitter;
					break;
				}
			};

			listView.SelectedItem = viewModel.MenuItems[0];
			layout.Children.Add(listView);

			Content = layout;
		}