protected override void OnResume() { base.OnResume(); if (test != null) { test.onTestEvent -= OnTestEvent; test.StopTest(); test = null; } grid.ReloadData(); }
public override void ViewWillAppear(bool animated) { base.ViewWillAppear(animated); if (this.ParentViewController.NavigationController != null) { var aButton = new UIBarButtonItem(UIBarButtonSystemItem.Action); aButton.Clicked += (object sender, EventArgs e) => { var alert = new UIActionSheet("Switch DataSets"); alert.AddButton("Example 1"); alert.AddButton("Example 2"); alert.AddButton("Cancel"); alert.CancelButtonIndex = 2; alert.Clicked += (object action, UIButtonEventArgs e2) => { var curName = mGridView.TableName; var newName = String.Empty; switch (e2.ButtonIndex) { case 0: { newName = ((DSDataSet)mGridView.DataSource).Tables [0].Name; } break; case 1: { newName = ((DSDataSet)mGridView.DataSource).Tables [1].Name; } break; } if (String.IsNullOrWhiteSpace(newName)) { return; } //check if the new name is different to the old name if (curName != newName) { mGridView.TableName = newName; mGridView.ReloadData(); } }; alert.ShowFrom((UIBarButtonItem)sender, true); }; this.ParentViewController.NavigationItem.LeftBarButtonItem = null; this.ParentViewController.NavigationItem.RightBarButtonItems = new UIBarButtonItem[] { aButton }; } }