Beispiel #1
0
        private void LoadData()
        {
            _sp.Children.Clear();
            DynamicJson courseList   = RestRC.BACARepository.Request(ApiList.courseList, string.Empty).AsDynamicJson();
            dynamic     categoryList = RestRC.BACARepository.Request(ApiList.categoryList, string.Empty).ToDynamicJson().list;

            if (categoryList != null)
            {
                foreach (DynamicJson category in categoryList)
                {
                    if (category.GetStr("type") != "1")
                    {
                        continue;
                    }
                    IndexInfo catelogElement = new IndexInfo()
                    {
                        model = category
                    };
                    catelogElement.Title.Content = category.GetStr("title");

                    foreach (DynamicJson course in courseList.GetChild <List <object> >("list"))
                    {
                        if (category.GetStr("id") == course.GetStr("basecoursecategoryid"))
                        {
                            CourseItem ci = new CourseItem();
                            ci._imgCourse.Source  = AppResources.GetImageSource(course.GetStr("coverimg"));
                            ci._imgCourse.Tag     = course.GetStr("Id");
                            ci._imgTeacher.Source = AppResources.GetImageSource(course.GetChild <DynamicJson>("teacherEntity").GetStr("headimg"));
                            ci._imgTeacher.Tag    = course.GetStr("teacherid");
                            ci._tblDesc.Text      = string.Format("教师:{0}\r\n{1}", course.GetChild <DynamicJson>("teacherEntity").GetStr("name"), course.GetStr("describeshort"));
                            catelogElement._wpCourseItems.Children.Add(ci);
                            ci._imgCourse.PreviewMouseLeftButtonUp  += _imgCourse_PreviewMouseLeftButtonUp;
                            ci._imgTeacher.PreviewMouseLeftButtonUp += _imgTeacher_PreviewMouseLeftButtonUp;
                        }
                    }
                    _sp.Children.Add(catelogElement);
                }
            }
        }