Пример #1
0
        public RentTabContent()
        {
            try
            {
                this.SetBinding(ContentPage.TitleProperty, "Name");
                this.SetBinding(ContentPage.IconProperty, "Icon");
                this.WidthRequest = 100;
                this.ToolbarItems.Clear();
                this.BackgroundColor = Color.Azure;
                ///==================================================
                listView = new ListView();
                //RestoreRents();
                _rentList                = new ObservableCollection <RentViewModel>();
                listView.ItemsSource     = _rentList;
                listView.RowHeight       = 80;
                listView.BackgroundColor = Color.White;
                listView.ItemTemplate    = new DataTemplate(typeof(RentView));
                listView.ItemTapped     += async(sender, e) =>
                {
                    RentViewModel item = (RentViewModel)e.Item;
                    await DisplayAlert("Информация", item.GetRentInfo(), "OK");

                    ((ListView)sender).SelectedItem = null;
                };
                ///==================================================
                var btn = new Button {
                    Text = "Новый", BackgroundColor = Color.White, TextColor = Color.Green
                };
                btn.Clicked += async(sender, args) =>
                {
                    var p = this.Title == "Gyro" ? new Person(_gyroPrices) : new Person(_cyclePrices);
                    p.AddNewRentInfo = AddNewRent;
                    await Navigation.PushAsync(p);
                };
                ///
                StackLayout viewLayout = new StackLayout()
                {
                    Orientation = StackOrientation.Vertical,
                    Padding     = new Thickness(5, 10, 5, 0),
                    Children    = { listView, btn }
                };
                Content = viewLayout;
            }
            catch (Exception ex)
            {
                App.Database.SaveError(new Mob.Dto.Error {
                    Date = DateTime.Now, Invoker = this.GetType().Name, Message = ex.Message
                });
            }
        }
Пример #2
0
 /// <summary>
 /// Delete rent from view
 /// </summary>
 /// <param name="rent">Rent</param>
 private void DeleteRent(RentViewModel rent)
 {
     try
     {
         _rentList.Remove(rent);
     }
     catch (Exception ex)
     {
         DisplayAlert("Ошибка", "Не могу удалить:(", "OK");
         App.Database.SaveError(new Mob.Dto.Error {
             Date = DateTime.Now, Invoker = this.GetType().Name, Message = ex.Message
         });
     }
 }