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); }
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); }
internal static IEnumerable <Element> GetParentsPath(this Element self) { Element current = self; while (!Application.IsApplicationOrNull(current.RealParent)) { current = current.RealParent; yield return(current); } }
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; } }
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; } }