예제 #1
0
        public PageHeader()
        {
            this.InitializeComponent();
            PrimaryCommands   = HeaderCommandBar.PrimaryCommands;
            SecondaryCommands = HeaderCommandBar.SecondaryCommands;
            this.Background   = HeaderCommandBar.Background;
            HeaderCommandBar.SetBinding(CommandBar.BackgroundProperty, new Binding
            {
                Path   = new PropertyPath(nameof(Background)),
                Source = this
            });

            Action updateEllipse = () =>
            {
                var controls = XamlUtil.AllChildren <Control>(HeaderCommandBar);
                var buttons  = controls.OfType <Button>();
                var button   = buttons.FirstOrDefault(x => x.Name.Equals("MoreButton"));
                if (button != null)
                {
                    var count = HeaderCommandBar.PrimaryCommands.OfType <Control>().Count(x => x.Visibility.Equals(Visibility.Visible));
                    count            += HeaderCommandBar.SecondaryCommands.OfType <Control>().Count(x => x.Visibility.Equals(Visibility.Visible));
                    button.Visibility = (count > 0) ? Visibility.Visible : Visibility.Collapsed;
                }
            };

            PrimaryCommands.VectorChanged += (s, e) => updateEllipse();
            HeaderCommandBar.Loaded       += (s, e) => updateEllipse();
        }
예제 #2
0
        private void Update()
        {
            var controls = XamlUtil.AllChildren <Control>(commandBar);
            var button   = controls.OfType <Button>().FirstOrDefault(x => x.Name.Equals("MoreButton"));

            if (button == null)
            {
                return;
            }
            switch (Visibility)
            {
            case Visibilities.Visible:
                button.Visibility = global::Windows.UI.Xaml.Visibility.Visible;
                break;

            case Visibilities.Collapsed:
                button.Visibility = global::Windows.UI.Xaml.Visibility.Collapsed;
                break;

            case Visibilities.Auto:
                var count = commandBar.PrimaryCommands.OfType <Control>().Count(x => x.Visibility.Equals(global::Windows.UI.Xaml.Visibility.Visible));
                count            += commandBar.SecondaryCommands.OfType <Control>().Count(x => x.Visibility.Equals(global::Windows.UI.Xaml.Visibility.Visible));
                button.Visibility = (count > 0) ? global::Windows.UI.Xaml.Visibility.Visible : global::Windows.UI.Xaml.Visibility.Collapsed;
                break;
            }
        }
 private void OnLoaded(object sender, RoutedEventArgs routedEventArgs)
 {
     var headers = XamlUtil.AllChildren<PivotHeaderItem>(this);
     foreach (var headerItem in headers)
     {
         headerItem.Height = double.NaN;
     }
 }
예제 #4
0
        private void UpdateEllipse()
        {
            if (_commandBar == null)
            {
                return;
            }
            var controls = XamlUtil.AllChildren <Control>(_commandBar);
            var buttons  = controls.OfType <Button>();
            var button   = buttons.FirstOrDefault(x => x.Name.Equals("MoreButton"));

            if (button != null)
            {
                var count =
                    _commandBar.PrimaryCommands.OfType <Control>().Count(x => x.Visibility.Equals(Visibility.Visible));
                count            += _commandBar.SecondaryCommands.OfType <Control>().Count(x => x.Visibility.Equals(Visibility.Visible));
                button.Visibility = (count > 0) ? Visibility.Visible : Visibility.Collapsed;
            }
        }