Пример #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",
                    FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label))
                }
            };

            layout.Children.Add(label);

            var listView = new ListView();

            DataTemplate cell = null;

            if (Device.OS == TargetPlatform.Windows)
            {
                cell = new DataTemplate(typeof(FancyListCell));
                this.BackgroundColor = Color.FromHex("3498DB");
            }
            else
            {
                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 AboutPage();
            }

            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 AboutPage();
                    }

                    PageSelection = about;
                    break;

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

                    PageSelection = blog;
                    break;

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

                    PageSelection = twitter;
                    break;

                case MenuType.DeveloperLife:
                    if (developerlife == null)
                    {
                        developerlife = new PodcastPage(menuItem);
                    }

                    PageSelection = developerlife;
                    break;

                case MenuType.Hanselminutes:
                    if (hanselminutes == null)
                    {
                        hanselminutes = new PodcastPage(menuItem);
                    }

                    PageSelection = hanselminutes;
                    break;

                case MenuType.Ratchet:
                    if (ratchet == null)
                    {
                        ratchet = new PodcastPage(menuItem);
                    }

                    PageSelection = ratchet;
                    break;
                }
            };

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

            Content = layout;
        }
Пример #2
0
 public PodcastPageViewModel(PodcastPage podcastPage, IServiceContext serviceContext)
     : base(serviceContext.GetService <IPodcastDataSource>(), serviceContext)
 {
     m_View        = podcastPage;
     m_MediaPlayer = serviceContext.GetService <IMediaPlayer>();
 }