コード例 #1
0
        public CourseMasterDetailDB()
        {
            var listView = new ListView();

            listView.ItemsSource   = PluralsightCourse.GetCourseList();
            listView.ItemSelected += (sender, e) =>
            {
                if (e.SelectedItem == null)
                {
                    return;
                }
                Detail.BindingContext = e.SelectedItem;

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

            Detail = new CoursePageDB();
            Detail.BindingContext = PluralsightCourse.GetCourseList().First();
        }
コード例 #2
0
        public HomePage()
        {
            Padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 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();
                page.Title = "Courses";
                foreach (var course in PluralsightCourse.GetCourseList())
                {
                    var coursePage = new CoursePageDB();
                    coursePage.BindingContext = course;
                    page.Children.Add(coursePage);
                }

                Navigation.PushAsync(page);
            };

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

            button5.Clicked += (o, e) =>
            {
                var page = new CarouselPage();
                page.Title = "Courses";
                foreach (var course in PluralsightCourse.GetCourseList())
                {
                    var coursePage = new CoursePageDB();
                    coursePage.BindingContext = course;
                    page.Children.Add(coursePage);
                }

                Navigation.PushAsync(page);
            };

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