/// <summary> /// Loads the view asynchronously. /// </summary> protected async Task LoadAsyncInternal(bool initiatedLoad, bool parentAwaitAssets) { if (IsLoaded) { return; } if (LoadMode.HasFlag(LoadMode.Manual) && !initiatedLoad) { return; } BeforeLoad(); bool awaitAssets = parentAwaitAssets || LoadMode.HasFlag(LoadMode.AwaitAssets); await Task.WhenAll(LayoutChildren.ToList().Select(x => x.LoadAsyncInternal(false, awaitAssets))); _isLoaded = true; AfterChildrenLoaded(); Initialize(); if (awaitAssets) { await LoadDependencyPropertiesAsync(); } else { LoadDependencyProperties(); } UpdateBindings(); AfterLoad(); Loaded?.Invoke(this); }
/// <summary> /// Loads the view. Called internally. /// </summary> protected void LoadInternal(bool initiatedLoad) { if (IsLoaded) { return; } if (LoadMode.HasFlag(LoadMode.Manual) && !initiatedLoad) { return; } BeforeLoad(); foreach (var child in LayoutChildren.ToList()) { child.LoadInternal(false); } _isLoaded = true; AfterChildrenLoaded(); Initialize(); LoadDependencyProperties(); UpdateBindings(); _initializer?.Invoke(this); AfterLoad(); Loaded?.Invoke(this); }
/// <summary> /// Unloads the view. /// </summary> protected void UnloadInternal() { if (!IsLoaded) { return; } BeforeUnload(); foreach (var child in LayoutChildren.ToList()) { child.UnloadInternal(); } AfterUnload(); UnloadDependencyProperties(); _isLoaded = false; if (IsDynamic) { Destroy(); } }