示例#1
0
        public SelectedProduct(string selectedProduct)
        {
            InitializeComponent();

            dup = new DriveUrselfProductsDBEntities1();

            productID = Convert.ToInt32(selectedProduct.Split('_')[1]);

            product product = dup.product.Find(Convert.ToInt32(selectedProduct.Split('_')[1]));

            MainImg.Source = new BitmapImage(new Uri(@"pack://siteoforigin:,,,/" + product.C_Главное_изображение));

            name.Text   = product.Наименование_товара;
            proz.Text   = product.C_Производитель;
            Active.Text = product.C_Активен_;
            cost.Text   = product.C_Цена;
        }
        public MainMenu()
        {
            InitializeComponent();

            dup = new DriveUrselfProductsDBEntities1();

            int i = 0;

            foreach (var product in dup.product)
            {
                i++;
                Image img = new Image();
                img.Width  = 100;
                img.Height = 100;
                img.Source = new BitmapImage(new Uri(@"pack://siteoforigin:,,,/" + product.C_Главное_изображение));
                img.Name   = "id_" + product.id.ToString();
                img.MouseLeftButtonDown += Image_MouseLeftButtonDown;

                Label lbl = new Label();
                lbl.Content = product.Наименование_товара.Substring(0, 20) + "...: " + product.C_Цена;


                grid.Height += 100;
                grid.Children.Add(img);
                grid.Children.Add(lbl);


                Canvas.SetTop(img, rowPos);
                Canvas.SetLeft(img, collumnPos);
                Canvas.SetTop(lbl, rowPos + img.Height);
                Canvas.SetLeft(lbl, collumnPos);

                if (i % 3 != 0)
                {
                    collumnPos += 250;
                }
                else
                {
                    rowPos    += 150;
                    collumnPos = 0;
                }
            }
        }