Пример #1
0
        public ShellSectionRenderer(ShellRenderer shellContext)
        {
            Xamarin.Forms.Shell.VerifyShellUWPFlagEnabled(nameof(ShellSectionRenderer));
            MenuItemTemplate    = (Windows.UI.Xaml.DataTemplate)Windows.UI.Xaml.Application.Current.Resources["ShellSectionMenuItemTemplate"];
            IsBackButtonVisible = Microsoft.UI.Xaml.Controls.NavigationViewBackButtonVisible.Collapsed;
            IsSettingsVisible   = false;
            AlwaysShowHeader    = false;
            PaneDisplayMode     = Microsoft.UI.Xaml.Controls.NavigationViewPaneDisplayMode.Top;
            ItemInvoked        += MenuItemInvoked;

            AutoSuggestBox = new Windows.UI.Xaml.Controls.AutoSuggestBox()
            {
                Width = 300
            };
            AutoSuggestBox.TextChanged      += SearchBox_TextChanged;
            AutoSuggestBox.QuerySubmitted   += SearchBox_QuerySubmitted;
            AutoSuggestBox.SuggestionChosen += SearchBox_SuggestionChosen;

            Frame    = new Windows.UI.Xaml.Controls.Frame();
            Content  = Frame;
            _context = shellContext;

            this.SizeChanged += ShellSectionRenderer_SizeChanged;
            Resources["NavigationViewTopPaneBackground"]            = new Windows.UI.Xaml.Media.SolidColorBrush(ShellRenderer.DefaultBackgroundColor);
            Resources["TopNavigationViewItemForeground"]            = new Windows.UI.Xaml.Media.SolidColorBrush(ShellRenderer.DefaultForegroundColor);
            Resources["TopNavigationViewItemForegroundSelected"]    = new Windows.UI.Xaml.Media.SolidColorBrush(ShellRenderer.DefaultForegroundColor);
            Resources["NavigationViewSelectionIndicatorForeground"] = new Windows.UI.Xaml.Media.SolidColorBrush(ShellRenderer.DefaultForegroundColor);
        }
Пример #2
0
 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();
     }
 }
Пример #3
0
        public ShellItemRenderer(ShellRenderer shellContext)
        {
            Xamarin.Forms.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);
        }