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