特定平台如何订阅PCL ViewModel中的事件

Lea*_*rin 0 xamarin.ios mvvmcross

我正在使用MVVMCross + PCL,需要在此PCL中的ViewModel上触发事件.我需要plafotm特定的iOS ViewController来监视这个事件.

我该怎样才能说明这一点?

谢谢,

Che*_*ron 5

为什么不创建一个常规的C#事件?

在您的ViewModel中:

public event EventHandler Something;
Run Code Online (Sandbox Code Playgroud)

在View/ViewController/Page中:

ViewModel.Something += (s, e) => Console.WriteLine("Something!");
Run Code Online (Sandbox Code Playgroud)