Created
October 14, 2014 19:48
-
-
Save johansson/a68979fd2cdbfa1217b1 to your computer and use it in GitHub Desktop.
This file contains 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
using System; | |
using ReactiveUI; | |
using System.Windows.Input; | |
using System.Threading; | |
using System.Threading.Tasks; | |
namespace RxUITestApp | |
{ | |
public class MainVM : ReactiveObject | |
{ | |
public ICommand HelloButton { get; private set; } | |
public MainVM() | |
{ | |
HelloButton = ReactiveCommand.CreateAsyncTask(async _ => { | |
await Task.Run(() => { | |
Console.WriteLine("About to sleep!"); | |
Thread.Sleep(5000); | |
Console.WriteLine("Done sleeping!"); | |
}); | |
}); | |
} | |
} | |
} | |
// === | |
using System; | |
using System.Drawing; | |
using MonoTouch.Foundation; | |
using MonoTouch.UIKit; | |
using ReactiveUI; | |
using System.ComponentModel; | |
namespace RxUITestApp | |
{ | |
public partial class RxUITestAppViewController : ReactiveViewController, IViewFor<MainVM> | |
{ | |
public MainVM ViewModel { | |
get; | |
set; | |
} | |
object IViewFor.ViewModel { | |
get { | |
return ViewModel; | |
} | |
set { | |
ViewModel = value as MainVM; | |
} | |
} | |
public RxUITestAppViewController(IntPtr handle) : base(handle) | |
{ | |
this.ViewModel = new MainVM(); | |
this.BindCommand(ViewModel, x => x.HelloButton, x => x.btnHello); | |
} | |
//... | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment