Пример #1
0
        protected override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            _contentPresenter = GetTemplateChild("ContentPresenter") as WContentPresenter;
            _rootGrid         = GetTemplateChild("RootGrid") as Microsoft.UI.Xaml.Controls.Grid;

            UpdateBackgroundColor();
            UpdateBorderRadius();
        }
Пример #2
0
        protected override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            _rootGrid = GetTemplateChild("RootGrid") as Microsoft.UI.Xaml.Controls.Grid;
            if (_rootGrid != null)
            {
                var stateGroups = WVisualStateManager.GetVisualStateGroups(_rootGrid).ToList();
                _DeleteButtonVisibleStateGroups = stateGroups.SingleOrDefault(sg => sg.Name == "ButtonStates");
                if (_DeleteButtonVisibleStateGroups != null)
                {
                    _DeleteButtonVisibleState = _DeleteButtonVisibleStateGroups.States.SingleOrDefault(s => s.Name == "ButtonVisible");
                }
                UpdateClearButtonVisible();
            }

            _scrollViewer = GetTemplateChild("ContentElement") as ScrollViewer;
        }
Пример #3
0
        public ShellItemRenderer(ShellRenderer shellContext)
        {
            Microsoft.Maui.Controls.Shell.VerifyShellUWPFlagEnabled(nameof(ShellItemRenderer));
            _ = 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);

            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);
        }