Instantly share code, notes, and snippets.

Embed
What would you like to do?
Xamarin.FormsでOnSleep・OnResumeをViewModelでハンドルする
public partial class App : Application
{
.....
protected override void OnSleep()
{
(MainPage.BindingContext as IApplicationLifecycle)?.OnSleep();
}
protected override void OnResume()
{
(MainPage.BindingContext as IApplicationLifecycle)?.OnResume();
}
}
public interface IApplicationLifecycle
{
void OnSleep();
void OnResume();
}
public class MainPageViewModel : IApplicationLifecycle
{
public void OnSleep()
{
}
public void OnResume()
{
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment