Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using Foundation;
- using UIKit;
- namespace Woozy
- {
- public abstract class AbstractWoozyTableViewSource<T> : UITableViewDataSource
- {
- private List<T> _data;
- public List<T> DataList
- {
- get { return _data; }
- set
- {
- _data = value;
- }
- }
- public delegate void CellRowSelectedEvent(T item);
- public event CellRowSelectedEvent RowSelectedEvent;
- public AbstractWoozyTableViewSource()
- {
- }
- public override nint RowsInSection(UITableView tableView, nint section)
- {
- if (_data != null)
- {
- return _data.Count;
- }
- return 0;
- }
- public void RowSelected(UITableView tableView, NSIndexPath indexPath)
- {
- tableView.DeselectRow(indexPath, true);
- T item = _data[indexPath.Row];
- if (RowSelectedEvent != null)
- {
- RowSelectedEvent(item);
- }
- }
- public static implicit operator UITableViewSource(AbstractWoozyTableViewSource<T> v)
- {
- return (UITableViewSource)v;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement