Advertisement
Guest User

Untitled

a guest
Nov 28th, 2014
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. public class MyView : MvxViewController{
  2. // other stuff
  3. public override void ViewWillAppear (bool animated)
  4. {
  5. var sourceOne = new MyCollectionViewSource (MyCollectionView, new NSString ("MyCollectionViewCell"));
  6. MyCollectionView.Source = sourceOne;
  7. var bindings = this.CreateBindingSet<MyView, MyViewModel> ();
  8.  
  9. bindings.Bind (sourceOne)
  10. .To (vm => vm.ItemList);
  11.  
  12. bindings.Apply ();
  13. MyCollectionView.ReloadData ();
  14. }
  15. }
  16.  
  17. public MyCollectionViewSource : MvxCollectionViewSource{
  18. protected override UICollectionViewCell GetOrCreateCellFor (UICollectionView collectionView, NSIndexPath indexPath, object item)
  19. {
  20. return collectionView.DequeueReusableCell (new NSString ("MyCollectionViewCell"), indexPath) as MyCollectionViewCell;
  21. }
  22. public override void WillDisplayCell (UICollectionView collectionView, UICollectionViewCell cell, NSIndexPath indexPath)
  23. {
  24. var cellz = cell as MyCollectionViewCell;
  25. cellz.ClearAllBindings ();
  26. cellz.BindUrl ();
  27. }
  28. }
  29.  
  30. public partial class MyCollectionViewCell : MvxCollectionViewCell {
  31. public MyCollectionViewCell (IntPtr handle) : base (handle)
  32. {
  33. BindUrl();
  34. }
  35. public void BindUrl()
  36. {
  37. this.ClearAllBindings ();
  38. this.DelayBind(() => {
  39. this.CreateBinding(MyWebView)
  40. .For(webView => webView.MyUrl)
  41. .To<ListItemViewModel>(vm => vm.UrlEntryPoint)
  42. .Apply();
  43. });
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement