_ Mac UI.txt 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. NOTE
  2. - Use Xamarin Studio for this...
  3. 0. Add a MonoMac or Xamarin.Mac Project
  4. 1. Add a reference to your Core PCL project, e.g., <root>.Core
  5. 2. Right-click on the project and under Tools -> Edit File, then add <TargetFrameworkVersion>4.5</TargetFrameworkVersion> in the first PropertyGroup, this is needed to access PCLs using Profile 158
  6. 3. Use nuget to add the MvvmCross.Mac package
  7. 4. Verify the Setup.cs file (automatically created)
  8. 5. Replace the contents of AppDelegate.cs from AppDelegate.cs.txt
  9. 6. Delete MainWindow.cs, MainWindow.xib and MainWindowController.cs
  10. 7. Create a Views folder and add a Cocao View and Controller, if the ViewModel is "FirstViewModel", recommended naming for the View is "FirstView"
  11. 8. Edit FirstView.cs by adding the using statement below and changing the base type to MvxView
  12. using Cirrious.MvvmCross.Binding.Mac.Views;
  13. public partial class FirstView : MvxView
  14. 9. Edit FirstViewController.cs by adding the using statements below, adding MvxViewFor and changing the base type to MvxViewController
  15. using Cirrious.MvvmCross.Mac.Views;
  16. using Cirrious.MvvmCross.Binding.BindingContext;
  17. using Cirrious.MvvmCross.ViewModels;
  18. using <root>.Core.ViewModels;
  19. [MvxViewFor(typeof(FirstViewModel))]
  20. public partial class FirstViewController : MvxViewController
  21. 10. In FirstViewController.cs, override ViewDidLoad, add controls programmatically or in the .xib, then bind, e.g.,
  22. public override void ViewDidLoad ()
  23. {
  24. base.ViewDidLoad ();
  25. ...
  26. var set = this.CreateBindingSet<FirstViewController, FirstViewModel> ();
  27. set.Bind (textEditFirst).For(v => v.StringValue).To (vm => vm.FirstName);
  28. set.Bind (textEditSecond).For(v => v.StringValue).To (vm => vm.LastName);
  29. set.Bind (labelFull).For(v => v.StringValue).To (vm => vm.FullName);
  30. set.Bind (bu).For("Activated").To ("GoCommand");
  31. set.Apply ();
  32. }
  33. s
  34. Where this requires using's of:
  35. using YourNameSpace.Core.ViewModels;
  36. using Cirrious.MvvmCross.Binding.BindingContext;
  37. using Cirrious.MvvmCross.Mac.Views;