所以我有一些填充了数据的ListView。我有项目点击处理程序。它看起来如此
var listview = FindViewById<ListView>(Resource.Id.myList);
listview .ItemClick += OnItemClick;
// populating listview items
MyModel[] someDataArray = GetData();
listview .Adapter = new MyAdapter(this, someDataArray );
....
protected async void OnItemClick(object sender, AdapterView.ItemClickEventArgs e)
{
// here i would like to perfom some actions with instance of MyModel
// associated with current ListView's Item
}
我想在OnItemClick事件处理程序中获取与ListView的Item关联的MyModel实例,但我不知道如何在此事件处理程序中获取此模型。
答案 0 :(得分:1)
Position
上有ItemClickEventArgs
个属性。所以,
MyModel model = someDataArray[e.Position];