internal void SetShellContext(ShellRenderer context) { if (ShellContext != null) { ((IShellController)ShellContext.Shell).RemoveAppearanceObserver(this); ((IShellController)ShellContext.Shell).RemoveFlyoutBehaviorObserver(this); } ShellContext = context; if (ShellContext != null) { ((IShellController)ShellContext.Shell).AddFlyoutBehaviorObserver(this); ((IShellController)ShellContext.Shell).AddAppearanceObserver(this, ShellContext.Shell); UpdateHeaderInsets(); } }
public ShellItemRenderer(ShellRenderer shellContext) { System.Maui.Shell.VerifyShellUWPFlagEnabled(nameof(ShellItemRenderer)); _ = shellContext ?? throw new ArgumentNullException(nameof(shellContext)); ShellContext = shellContext; RowDefinitions.Add(new UwpRowDefinition() { Height = new UwpGridLength(1, UwpGridUnitType.Auto) }); RowDefinitions.Add(new UwpRowDefinition() { Height = new UwpGridLength(1, UwpGridUnitType.Star) }); RowDefinitions.Add(new UwpRowDefinition() { Height = new UwpGridLength(1, UwpGridUnitType.Auto) }); _Title = new TextBlock() { Style = Resources["SubtitleTextBlockStyle"] as UwpStyle, VerticalAlignment = VerticalAlignment.Center, TextTrimming = TextTrimming.CharacterEllipsis, TextWrapping = TextWrapping.NoWrap }; _HeaderArea = new UwpGrid() { Height = 40, Padding = new UwpThickness(10, 0, 10, 0) }; _HeaderArea.ColumnDefinitions.Add(new UwpColumnDefinition() { Width = new UwpGridLength(1, UwpGridUnitType.Star) }); _HeaderArea.ColumnDefinitions.Add(new UwpColumnDefinition() { Width = new UwpGridLength(1, UwpGridUnitType.Auto) }); _HeaderArea.Children.Add(_Title); Children.Add(_HeaderArea); _Toolbar = new ItemsControl() { ItemTemplate = UwpApplication.Current.Resources["ShellToolbarItemTemplate"] as UwpDataTemplate, ItemsPanel = UwpApplication.Current.Resources["ShellToolbarItemsPanelTemplate"] as ItemsPanelTemplate, }; SetColumn(_Toolbar, 1); _HeaderArea.Children.Add(_Toolbar); SectionRenderer = shellContext.CreateShellSectionRenderer(); SetRow(SectionRenderer, 1); Children.Add(SectionRenderer); _BottomBar = new UwpGrid() { HorizontalAlignment = HorizontalAlignment.Center }; _BottomBarArea = new Border() { Child = _BottomBar }; SetRow(_BottomBarArea, 2); Children.Add(_BottomBarArea); }