private void DetachVisibilityHandler(WindowCommandsItem container) { if (container != null) { container.VisibilityPropertyChangeNotifier = null; } }
private void AttachVisibilityHandler(WindowCommandsItem container, UIElement item) { if (container != null) { if (null == item) { // if item is not a UIElement then maybe the ItemsSource binds to a collection of objects // and an ItemTemplate is set, so let's try to solve this container.ApplyTemplate(); var content = container.ContentTemplate?.LoadContent() as UIElement; if (null == content) { // no UIElement was found, so don't show this container container.Visibility = Visibility.Collapsed; } return; } container.Visibility = item.Visibility; var isVisibilityNotifier = new PropertyChangeNotifier(item, VisibilityProperty); isVisibilityNotifier.ValueChanged += this.VisibilityPropertyChanged; container.VisibilityPropertyChangeNotifier = isVisibilityNotifier; } }
private WindowCommandsItem GetWindowCommandsItem(object item) { WindowCommandsItem windowCommandsItem = item as WindowCommandsItem; if (windowCommandsItem != null) { return(windowCommandsItem); } return((WindowCommandsItem)base.ItemContainerGenerator.ContainerFromItem(item)); }
private void VisibilityPropertyChanged(object sender, EventArgs e) { UIElement uIElement = sender as UIElement; if (uIElement != null) { WindowCommandsItem windowCommandsItem = this.GetWindowCommandsItem(uIElement); if (windowCommandsItem != null) { windowCommandsItem.Visibility = uIElement.Visibility; this.ResetSeparators(true); } } }
private void AttachVisibilityHandler(WindowCommandsItem container, UIElement item) { if (container != null) { if (item == null) { container.Visibility = System.Windows.Visibility.Collapsed; return; } container.Visibility = item.Visibility; PropertyChangeNotifier propertyChangeNotifier = new PropertyChangeNotifier(item, UIElement.VisibilityProperty); propertyChangeNotifier.ValueChanged += new EventHandler(this.VisibilityPropertyChanged); container.VisibilityPropertyChangeNotifier = propertyChangeNotifier; } }
private void AttachVisibilityHandler(WindowCommandsItem container, UIElement item) { if (container != null) { // hide the container, if there is no UIElement if (null == item) { container.Visibility = Visibility.Collapsed; return; } container.Visibility = item.Visibility; var isVisibilityNotifier = new PropertyChangeNotifier(item, UIElement.VisibilityProperty); isVisibilityNotifier.ValueChanged += VisibilityPropertyChanged; container.VisibilityPropertyChangeNotifier = isVisibilityNotifier; } }
private void ResetSeparators(bool reset = true) { if (base.Items.Count == 0) { return; } List <WindowCommandsItem> list = this.GetWindowCommandsItems().ToList <WindowCommandsItem>(); if (reset) { foreach (WindowCommandsItem showSeparators in list) { showSeparators.IsSeparatorVisible = this.ShowSeparators; } } WindowCommandsItem windowCommandsItem = list.LastOrDefault <WindowCommandsItem>((WindowCommandsItem i) => i.IsVisible); if (windowCommandsItem != null) { windowCommandsItem.IsSeparatorVisible = (!this.ShowSeparators ? false : this.ShowLastSeparator); } }
private void AttachVisibilityHandler(WindowCommandsItem container, UIElement item) { if (container != null) { if (null == item) { // if item is not a UIElement then maybe the ItemsSource binds to a collection of objects // and an ItemTemplate is set, so let's try to solve this container.ApplyTemplate(); var content = container.ContentTemplate?.LoadContent() as UIElement; if (null == content) { // no UIElement was found, so don't show this container container.Visibility = Visibility.Collapsed; } return; } container.Visibility = item.Visibility; var isVisibilityNotifier = new PropertyChangeNotifier(item, UIElement.VisibilityProperty); isVisibilityNotifier.ValueChanged += VisibilityPropertyChanged; container.VisibilityPropertyChangeNotifier = isVisibilityNotifier; } }