Inheritance: System.Windows.Controls.ContentControl
Esempio n. 1
0
 private void DetachVisibilityHandler(WindowCommandsItem container)
 {
     if (container != null)
     {
         container.VisibilityPropertyChangeNotifier = null;
     }
 }
Esempio n. 2
0
        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;
            }
        }
Esempio n. 3
0
        private WindowCommandsItem GetWindowCommandsItem(object item)
        {
            WindowCommandsItem windowCommandsItem = item as WindowCommandsItem;

            if (windowCommandsItem != null)
            {
                return(windowCommandsItem);
            }
            return((WindowCommandsItem)base.ItemContainerGenerator.ContainerFromItem(item));
        }
Esempio n. 4
0
        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);
                }
            }
        }
Esempio n. 5
0
 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;
     }
 }
Esempio n. 6
0
        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;
            }
        }
Esempio n. 7
0
        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 DetachVisibilityHandler(WindowCommandsItem container)
 {
     if (container != null)
     {
         container.VisibilityPropertyChangeNotifier = null;
     }
 }
        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;
            }
        }
Esempio n. 10
0
        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;
            }
        }