Xamarin.Forms: Does anyone know the equivalent of WillEnterForeground and DidEnterBackground in Xamarin.Forms?

I am rewriting an application that I wrote in Xamarin.iOS, in Xamarin.Forms, and I had some code to execute on DidEnterBackground and WillEnterForeground. Now I can not find the equivalent method in Xamarin.Forms. I tried mainPage.Appearing and mainPage.Disappearing in my App class, but they seem to be different from what I'm trying to achieve. Is anyone

+4
source share
1 answer

, Xamarin.Forms . Xamarin.Forms.Labs( NuGet) XFormsApplicationDelegate. GitHub.

public partial class AppDelegate : XFormsApplicationDelegate
{

IXFormsApp DI:

    private void SetIoc()
    {
        var resolverContainer = new SimpleContainer();

        var app = new XFormsAppiOS();
        app.Init(this);

        resolverContainer.Register<IXFormsApp>(app);

        Resolver.SetResolver(resolverContainer.GetResolver());
    }

DI, /PCL- Resolver. . .

        var app = Resolver.Resolve<IXFormsApp>();
        if (app == null)
        {
            return;
        }

        app.Closing += (o, e) => Debug.WriteLine("Application Closing");
        app.Error += (o, e) => Debug.WriteLine("Application Error");
        app.Initialize += (o, e) => Debug.WriteLine("Application Initialized");
        app.Resumed += (o, e) => Debug.WriteLine("Application Resumed");
        app.Rotation += (o, e) => Debug.WriteLine("Application Rotated");
        app.Startup += (o, e) => Debug.WriteLine("Application Startup");
        app.Suspended += (o, e) => Debug.WriteLine("Application Suspended");
+4

Source: https://habr.com/ru/post/1547242/


All Articles