コード例 #1
0
        public Window_MyBook()
        {
            InitializeComponent();


            var PhotoList = global::PhotoDataModel_V2.PhotoDataSource.Search("car", 5);

            for (int i = 1; i <= PhotoList.Count - 1; i++)
            {
                UserControl_Page Page = new UserControl_Page();
                Page.Desc     = PhotoList[i].Title;
                Page.ImageURL = PhotoList[i].ImagePath;

                this.MyBook.Items.Add(Page);
            }


            //=========================================================
            global::DataModel.AdventureWorksEntities dbContext = new DataModel.AdventureWorksEntities();
            var ProdutList = dbContext.ProductPhoto.ToList();

            for (int i = 1; i <= ProdutList.Count - 1; i++)
            {
                UserControl_Page Page = new UserControl_Page();
                Page.Desc      = ProdutList[i].ModifiedDate.ToShortDateString();
                Page.Imagebyte = ProdutList[i].LargePhoto;
                this.MyBook.Items.Add(Page);
            }
        }
コード例 #2
0
        public Window_MetroUI()
        {
            InitializeComponent();

            System.Random r = new Random();
            global::DataModel.AdventureWorksEntities dbContext = new DataModel.AdventureWorksEntities();

            var q = from p in dbContext.ProductPhoto
                    group p by p.ModifiedDate.Year;

            foreach (var group in q)
            {
                WrapPanel w = new WrapPanel();
                //w.Width = 200;
                w.Height      = 200;
                w.Background  = new SolidColorBrush(Colors.AliceBlue);
                w.Margin      = new Thickness(3);
                w.Orientation = Orientation.Vertical;//垂直顯示


                this.stackPanel.Children.Add(w);


                //foreach(var item in group)
                //{
                //    Button btn = new Button();
                //    btn.Width = 50;
                //    btn.Height = 50;
                //    btn.Content = item.ModifiedDate;
                //    btn.Margin = new Thickness(3);

                //    w.Children.Add(btn);
                //}

                foreach (var item in group)
                {
                    UserControl_Page up = new UserControl_Page();
                    up.Desc      = item.ModifiedDate.ToString();
                    up.Width     = 50;
                    up.Height    = 50;
                    up.Margin    = new Thickness(3);
                    up.Imagebyte = item.LargePhoto;

                    w.Children.Add(up);
                }
            }
        }