public void OnLayoutLoaded(LayoutLoadedArgs args) { var matchingAnchorables = args.LayoutAnchorables.Where(anch => anch.Content.GetType() == Definition.View && anch.Content.SafeCast <UserControl>().DataContext.GetType() == Definition.ViewModel && anch.IsVisible); var rougeAnchorables = ActivePanels.Where(o => !matchingAnchorables.Select(anch => anch.Content.SafeCast <UserControl>().DataContext). Contains(o.Content.SafeCast <UserControl>().DataContext)); foreach (var anchorable in rougeAnchorables.ToList()) { RemoveDynamicPanel(anchorable); } foreach (var invalidationSubscription in InvalidationSubscriptions) { invalidationSubscription.Event.Unsubscribe(invalidationSubscription.Token); } InvalidationSubscriptions.Clear(); ActivePanels.Clear(); foreach (var anchorable in matchingAnchorables) { ResolveDynamicPanelDependencies(anchorable); ActivePanels.Add(anchorable); } SyncSelection(ActivePanels.Select(o => o.Content.SafeCast <UserControl>().DataContext)); }
public static void AddPanel(ScreenSafePanel panel) { if (ActivePanels.Contains(panel)) { return; } ActivePanels.Add(panel); panel.ApplySafeArea(_currentSafeArea); }
private void AddDynamicPanel(LayoutAnchorable anchorable) { var container = GetPrefferedLayoutContainer(); container.Children.Add(anchorable); container.SelectedContentIndex = container.Children.IndexOf(anchorable); ResolveDynamicPanelDependencies(anchorable); ActivePanels.Add(anchorable); }