Esempio n. 1
0
        internal static T FindParentOfType <T>(this Element element)
        {
            var navPage = element
                          .GetParentsPath()
                          .OfType <T>()
                          .FirstOrDefault();

            return(navPage);
        }
Esempio n. 2
0
        internal static IMauiContext FindMauiContextOnParent(this Element element)
        {
            var navPage = element
                          .GetParentsPath()
                          .OfType <IView>()
                          .Where(x => x.Handler?.MauiContext != null)
                          .FirstOrDefault();

            return(navPage?.Handler?.MauiContext);
        }
Esempio n. 3
0
        internal static IMauiContext?FindMauiContext(this Element element)
        {
            if (element is Maui.IElement fe && fe.Handler?.MauiContext != null)
            {
                return(fe.Handler.MauiContext);
            }

            foreach (var parent in element.GetParentsPath())
            {
                if (parent is Maui.IElement parentView && parentView.Handler?.MauiContext != null)
                {
                    return(parentView.Handler.MauiContext);
                }
            }

            return(default);
Esempio n. 4
0
        internal static IMauiContext?FindMauiContext(this Element element, bool fallbackToAppMauiContext = false)
        {
            if (element is Maui.IElement fe && fe.Handler?.MauiContext != null)
            {
                return(fe.Handler.MauiContext);
            }

            foreach (var parent in element.GetParentsPath())
            {
                if (parent is Maui.IElement parentView && parentView.Handler?.MauiContext != null)
                {
                    return(parentView.Handler.MauiContext);
                }
            }

            return(fallbackToAppMauiContext ? Application.Current?.FindMauiContext() : default);