コード例 #1
0
        private void SelectedSouvenir(object sender, EventArgs e)
        {
            if (stackLayout1.Children.Count > 5)
            {
                stackLayout1.Children.RemoveAt(4);
                stackLayout1.Children.RemoveAt(4);
            }

            Souvenir souvenir = souvenirs[picker1.SelectedIndex];

            TableView tableView = new TableView
            {
                Intent = TableIntent.Form,
                Root   = new TableRoot()
                {
                    new TableSection("Информация о сувенире")
                    {
                        new TextCell
                        {
                            Text   = "Название:",
                            Detail = souvenir.Name
                        },
                        new TextCell
                        {
                            Text   = "Производитель:",
                            Detail = souvenir.Maker
                        },
                        new TextCell
                        {
                            Text   = "Цена:",
                            Detail = souvenir.Price.ToString()
                        },
                        new TextCell
                        {
                            Text   = "Дата продажи:",
                            Detail = Convert.ToDateTime(souvenir.Date).ToShortDateString()
                        }
                    }
                }
            };

            Button buttonBack = new Button();

            buttonBack.Text     = "Назад";
            buttonBack.Clicked += OnButtonBackFromMainClicked;
            stackLayout1.Children.Add(tableView);
            stackLayout1.Children.Add(buttonBack);
        }
コード例 #2
0
        public MainPage()
        {
            InitializeComponent();
            mainPage  = this.Content;
            souvenirs = new List <Souvenir>();
            Souvenir souvenir1 = new Souvenir()
            {
                Name  = "Брелок",
                Maker = "ABC",
                Price = 1000,
                Date  = Convert.ToDateTime("20.10.2020")
            };
            Souvenir souvenir2 = new Souvenir()
            {
                Name  = "Майка",
                Maker = "Vsemayki",
                Price = 4000,
                Date  = Convert.ToDateTime("11.03.2019")
            };
            Souvenir souvenir3 = new Souvenir()
            {
                Name  = "Флажок",
                Maker = "Yewa",
                Price = 400,
                Date  = Convert.ToDateTime("15.07.2020")
            };

            souvenirs.Add(souvenir1);
            souvenirs.Add(souvenir2);
            souvenirs.Add(souvenir3);
            picker1.Items.Add(souvenir1.Name);
            picker1.Items.Add(souvenir2.Name);
            picker1.Items.Add(souvenir3.Name);

            picker1.SelectedIndexChanged += SelectedSouvenir;
            buttondAdd.Clicked           += OnButtonAddClicked;
        }