Skip to content

Instantly share code, notes, and snippets.

@nuitsjp nuitsjp/App.xaml.cs
Last active Aug 2, 2017

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
You can’t perform that action at this time.