モノタッチのテーブルビューに表示される削除ボタンをViewModelのコマンドにバインドする必要がありますか?
1070 次
1 に答える
1
1つの方法は、MyItemType(ViewModelのコレクションで使用される)を変更して、を含むようにし、次のPleaseDeleteMeCommand
ように呼び出すことです。
public override void CommitEditingStyle(UITableView tableView, UITableViewCellEditingStyle editingStyle, NSIndexPath indexPath)
{
if (editingStyle == UITableViewCellEditingStyle.Delete)
{
var item = (MyItemType)GetItemAt(indexPath);
item.PleaseDeleteMeCommand.Execute(null);
}
base.CommitEditingStyle(tableView, editingStyle, indexPath);
}
別の方法は、代わりに所有しているViewModelにコマンドを追加することです。
public override void CommitEditingStyle(UITableView tableView, UITableViewCellEditingStyle editingStyle, NSIndexPath indexPath)
{
if (editingStyle == UITableViewCellEditingStyle.Delete)
{
var item = (MyItemType)GetItemAt(indexPath);
viewModel.PleaseDeleteItemCommand.Execute(item);
}
base.CommitEditingStyle(tableView, editingStyle, indexPath);
}
どちらの方法も、必要に応じて宣言型データバインディングを使用するように適合させることができます。関連するViewModel側のICommandをクライアント側のプロパティにバインドするだけです。
もちろん、組み込みのテーブル削除ボタンの代わりにカスタムボタンを使用して同じ機能を実装することもできます。ビデオhttp://slodge.blogspot.co.uk/2013/01/uitableviewcell-using-xib-editorを参照してください。ペットショップが子猫を販売する方法(行の削除を含む)のhtml 。
于 2013-02-05T07:48:55.173 に答える