示例#1
0
        public static async Task <Element> FindTemplatedParentAsync(Element element)
        {
            if (element.RealParent is Application)
            {
                return(null);
            }

            var skipCount = 0;

            element = await GetRealParentAsync(element);

            while (!Application.IsApplicationOrNull(element))
            {
                var controlTemplated = element as IControlTemplated;
                if (controlTemplated?.ControlTemplate != null)
                {
                    if (skipCount == 0)
                    {
                        return(element);
                    }
                    skipCount--;
                }
                if (element is ContentPresenter)
                {
                    skipCount++;
                }
                element = await GetRealParentAsync(element);
            }

            return(null);
        }
示例#2
0
 protected override void OnParentSet()
 {
     if (!Application.IsApplicationOrNull(RealParent) && !(RealParent is Page))
     {
         throw new InvalidOperationException("Parent of a Page must also be a Page");
     }
     base.OnParentSet();
 }
        Page AncestorToRoot(Page ancestor)
        {
            Page result = ancestor;

            while (!Application.IsApplicationOrNull(result.RealParent))
            {
                result = (Page)result.RealParent;
            }
            return(result);
        }
示例#4
0
        internal static IEnumerable <Element> GetParentsPath(this Element self)
        {
            Element current = self;

            while (!Application.IsApplicationOrNull(current.RealParent))
            {
                current = current.RealParent;
                yield return(current);
            }
        }
示例#5
0
		static void OnFlyoutBehaviorChanged(BindableObject bindable, object oldValue, object newValue)
		{
			var element = (Element)bindable;

			while (!Application.IsApplicationOrNull(element))
			{
				if (element is Shell shell)
					shell.NotifyFlyoutBehaviorObservers();
				element = element.Parent;
			}
		}
示例#6
0
        static void OnColorValueChanged(BindableObject bindable, object oldValue, object newValue)
        {
            var item   = (Element)bindable;
            var source = item;

            while (!Application.IsApplicationOrNull(item))
            {
                if (item is IShellController shell)
                {
                    shell.AppearanceChanged(source, true);
                    return;
                }
                item = item.Parent;
            }
        }