/// <summary> /// 新規ボタンをタップ /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BtnNew_Click(object sender, System.EventArgs e) { var item = ToDo.CreateNew(); var intent = new Intent(this, typeof(DetailActivity)); // データをシリアライズして渡す var data = Newtonsoft.Json.JsonConvert.SerializeObject(item); intent.PutExtra("data", data); StartActivityForResult(intent, 2); }
/// <summary> /// セグエの実行時 /// </summary> /// <param name="segue"></param> /// <param name="sender"></param> public override void PrepareForSegue(UIStoryboardSegue segue, NSObject sender) { /// 項目を選択したとき if (segue.Identifier == "showDetail") { var indexPath = TableView.IndexPathForSelectedRow; var item = items[indexPath.Row]; ((DetailViewController)segue.DestinationViewController).SetDetailItem(item); } else if (segue.Identifier == "showDetailForAdd") { var item = ToDo.CreateNew(); ((DetailViewController)segue.DestinationViewController).SetDetailItem(item); } else if (segue.Identifier == "showSetting") { ((SettingViewController)segue.DestinationViewController).AppSetting = setting; } }
/// <summary> /// 新規ボタンをタップ /// </summary> /// <param name="sender"></param> /// <param name="e"></param> async void AddItem_Clicked(object sender, EventArgs e) { var item = ToDo.CreateNew(); await Navigation.PushAsync(new DetailPage(item)); }