Last active
August 29, 2015 14:02
-
-
Save chkimes/ad6d8ee6bf4edf3f3ff0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MvxCustomTableViewSource<T> : MvxTableViewSource where T : UITableViewCell | |
{ | |
private readonly string _cellIdentifier; | |
public MvxCustomTableViewSource(UITableView tableView) : this(tableView, typeof(T).ToString()) | |
{ | |
} | |
public MvxCustomTableViewSource(UITableView tableView, string cellIdentifier) : base(tableView) | |
{ | |
_cellIdentifier = cellIdentifier; | |
tableView.RegisterClassForCellReuse(typeof(T), new NSString(cellIdentifier)); | |
} | |
[Obsolete("Unsupported", true)] | |
public MvxCustomTableViewSource(IntPtr handle) : base(handle) | |
{ | |
} | |
protected override UITableViewCell GetOrCreateCellFor(UITableView tableView, NSIndexPath indexPath, object item) | |
{ | |
return tableView.DequeueReusableCell(_cellIdentifier); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SomeViewController : MvxViewController | |
{ | |
... | |
private void SetUpTable() | |
{ | |
var tableView = new UITableView(); | |
Add(tableView); | |
var source = new MvxCustomTableViewSource<MyCustomTableViewCell>(_tableView); | |
tableView.Source = source; | |
var set = this.CreateBindingSet<SomeViewController, SomeViewModel>(); | |
set.Bind(source).To(vm => vm.SomeCollection); | |
set.Apply(); | |
} | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment