public CourseMasterDetailDB()
        {
            var listView = new ListView();

            listView.ItemsSource = PluralsightCourse.GetCourseList();

            listView.ItemSelected += (s, e) =>
            {
                if (e.SelectedItem != null)
                {
                    Detail.BindingContext = e.SelectedItem;
                }
            };

            Master = new ContentPage
            {
                Title   = "Courses",
                Content = listView
            };

            Detail = new CoursePageDB();
            Detail.BindingContext = PluralsightCourse.GetCourseList().First();
        }
Пример #2
0
        public HomePage()
        {
            Padding = new Thickness(10, 20, 10, 0);
            Title   = "Pages";

            var button1 = new Button {
                Text = "Simple Page"
            };

            button1.Clicked += (o, e) =>
            {
                Navigation.PushAsync(new CoursePage(PluralsightCourse.GetCourseList().First()));
            };

            var button2 = new Button {
                Text = "Master/Detail"
            };

            button2.Clicked += (o, e) =>
            { Navigation.PushAsync(new CourseMasterDetail()); };

            var button3 = new Button {
                Text = "Master/Detail (binding)"
            };

            button3.Clicked += (o, e) =>
            { Navigation.PushAsync(new CourseMasterDetailDB()); };

            var button4 = new Button {
                Text = "Tabbed"
            };

            button4.Clicked += (o, e) =>
            {
                var page = new TabbedPage
                {
                    Title = "Courses"
                };

                foreach (var course in PluralsightCourse.GetCourseList())
                {
                    var coursePage = new CoursePageDB {
                        BindingContext = course
                    };
                    page.Children.Add(coursePage);
                }

                Navigation.PushAsync(page);
            };

            var button5 = new Button {
                Text = "Carousel"
            };

            button5.Clicked += (o, e) =>
            {
                var page = new CarouselPage
                {
                    Title = "Courses"
                };

                foreach (var course in PluralsightCourse.GetCourseList())
                {
                    var coursePage = new CoursePageDB
                    {
                        BindingContext = course
                    };
                    page.Children.Add(coursePage);
                }

                Navigation.PushAsync(page);
            };

            Content = new StackLayout
            {
                Spacing  = 10,
                Children = { button1, button2, button3, button4, button5 }
            };
        }