public override void ViewDidLoad() { base.ViewDidLoad(); AddButton.SetCommand(ViewModel.AddAllToCartCommand); GenerateButton.SetCommand(ViewModel.GenerateGroupCommand); InitCollectionView(); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Lists); // Create the adapter using the default CachingViewHolder _adapter = Vm.Items.GetRecyclerAdapter( BindViewHolder, Resource.Layout.ItemTemplate, OnItemClick); MyRecycler.SetLayoutManager(new LinearLayoutManager(this)); MyRecycler.SetAdapter(_adapter); _bindings.Add( this.SetBinding( () => _adapter.SelectedItem.Name, () => SelectedItemNameText.Text, fallbackValue: "Nothing selected")); _bindings.Add( this.SetBinding( () => Vm.ToggledItems, () => ToggledItemsText.Text)); AddButton.SetCommand(Vm.AddCommand); var selectedItemBinding = this.SetBinding(() => _adapter.SelectedItem); _bindings.Add(selectedItemBinding); RemoveButton.SetCommand(Vm.DeleteCommand, selectedItemBinding); // Subscribing to events to avoid linker issues in release mode --------------------------------- // This "fools" the linker into believing that the events are used. // In fact we don't even subscribe to them. // See https://developer.xamarin.com/guides/android/advanced_topics/linking/ if (_falseFlag) { AddButton.Click += (s, e) => { }; RemoveButton.Click += (s, e) => { }; } }
public override void ViewDidLoad() { base.ViewDidLoad(); AddButton.SetCommand(ViewModel.AddAllToCartCommand); GenerateButton.SetCommand(ViewModel.GenerateGroupCommand); TableView.RegisterNibForCellReuse(ProductTableViewCell.Nib, ProductTableViewCell.Key); TableView.RegisterNibForHeaderFooterViewReuse(GroupedTableHeaderView.Nib, GroupedTableHeaderView.Key); TableView.RegisterClassForHeaderFooterViewReuse(typeof(GroupedTableFooterView), nameof(GroupedTableFooterView)); TableView.Source = new CustomSource(TableView, ViewModel.ProductListViewModel.Products) { HeightForRow = 60f, HeightForHeader = 40f, HeightForFooter = 20f }; }