public PastPurchases() { this.InitializeComponent(); ViewModel = new PastPurchasesViewModel(ServiceRegistrar.ShoppingService(App.SqliteConnection)); PastPurchasesListView.ItemsSource = ViewModel.Items; // Developer will want to return to none selection when selected items are zero PastPurchasesListView.SelectionChanged += OnSelectionChanged; // With this property we enable that the left edge tap visual indicator shows // when user press the listviewitem left edge // and also the ItemLeftEdgeTapped event will be fired // when user releases the pointer PastPurchasesListView.IsItemLeftEdgeTapEnabled = true; // This is event that will be fired when user releases the pointer after // pressing on the left edge of the ListViewItem PastPurchasesListView.ItemLeftEdgeTapped += OnEdgeTapped; // We set the state of the commands on the appbar SetCommandsVisibility(PastPurchasesListView); // This is how devs can handle the back button SystemNavigationManager.GetForCurrentView().BackRequested += OnBackRequested; }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { this._inflater = inflater; View view = inflater.Inflate(Resource.Layout.ic_tab_shopping_list, null); ViewModel = new ShoppingListViewModel(ServiceRegistrar.ShoppingService(MainActivity.SqliteConnection)); _shoppingListView = view.FindViewById <ListView>(Resource.Id.ShoppingListView); var newItemEditText = view.FindViewById <EditText>(Resource.Id.NewItemEditText); Button addItemButton = view.FindViewById <Button>(Resource.Id.AddButton); _shoppingListView.Adapter = ViewModel.Items.GetAdapter(GetItemView); addItemButton.Click += delegate { var title = newItemEditText.Text; if (!string.IsNullOrEmpty(title)) { ViewModel.Add(new Item(title)); } newItemEditText.Text = ""; }; _shoppingListView.ItemClick += delegate(object sender, AdapterView.ItemClickEventArgs e) { ViewModel.Remove(this.ViewModel.Items.ElementAt(e.Position)); }; return(view); }
private string[] GetSuggestions(string text) { return (ServiceRegistrar.ShoppingService(App.SqliteConnection).BoughtItems .Where(boughtItem => boughtItem.Title.ToLower().Contains(text.ToLower()) && ServiceRegistrar.ShoppingService(App.SqliteConnection).Items.All(x => !string.Equals(x.Title, boughtItem.Title, StringComparison.CurrentCultureIgnoreCase))) .Select(x => x.Title) .ToArray()); }
public override void ViewDidLoad() { base.ViewDidLoad(); // Perform any additional setup after loading the view, typically from a nib. AddNewItemButton.TouchUpInside += (sender, e) => { var title = NewItemTextField.Text; ServiceRegistrar.ShoppingService(Application.SqliteConnection).TryAddItemToShoppingList(new Item(title)); NavigationController.PopToRootViewController(true); }; }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { this._inflater = inflater; View view = inflater.Inflate(Resource.Layout.ic_tab_past_purchases, null); ViewModel = new PastPurchasesViewModel(ServiceRegistrar.ShoppingService(MainActivity.SqliteConnection)); _pastPurchasesListView = view.FindViewById <ListView>(Resource.Id.PastPurchasesListView); _pastPurchasesListView.Adapter = ViewModel.Items.GetAdapter(GetItemView); _pastPurchasesListView.ItemClick += delegate(object sender, AdapterView.ItemClickEventArgs e) { ViewModel.CopyItemToShoppingList(this.ViewModel.Items.ElementAt(e.Position)); }; return(view); }
public PastPurchasesTableSource() { ViewModel = new PastPurchasesViewModel(ServiceRegistrar.ShoppingService(Application.SqliteConnection)); }
public ShoppingListTableSource() { ViewModel = new ShoppingListViewModel(ServiceRegistrar.ShoppingService(Application.SqliteConnection)); }