示例#1
0
 internal void SetShellContext(ShellView 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();
     }
 }
示例#2
0
        public ShellItemView(ShellView shellContext)
        {
            _ = shellContext ?? throw new ArgumentNullException(nameof(shellContext));

            ShellContext = shellContext;
            RowDefinitions.Add(new UwpRowDefinition()
            {
                Height = WinUIHelpers.CreateGridLength(1, UwpGridUnitType.Auto)
            });
            RowDefinitions.Add(new UwpRowDefinition()
            {
                Height = WinUIHelpers.CreateGridLength(1, UwpGridUnitType.Star)
            });
            RowDefinitions.Add(new UwpRowDefinition()
            {
                Height = WinUIHelpers.CreateGridLength(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 = WinUIHelpers.CreateThickness(10, 0, 10, 0)
            };
            _HeaderArea.ColumnDefinitions.Add(new UwpColumnDefinition()
            {
                Width = WinUIHelpers.CreateGridLength(1, UwpGridUnitType.Star)
            });
            _HeaderArea.ColumnDefinitions.Add(new UwpColumnDefinition()
            {
                Width = WinUIHelpers.CreateGridLength(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);

            SectionView = shellContext.CreateShellSectionView();
            SetRow(SectionView, 1);

            Children.Add(SectionView);

            _BottomBar = new UwpGrid()
            {
                HorizontalAlignment = HorizontalAlignment.Center
            };
            _BottomBarArea = new WBorder()
            {
                Child = _BottomBar
            };
            SetRow(_BottomBarArea, 2);
            Children.Add(_BottomBarArea);
        }