Ejemplo n.º 1
0
        protected override DependencyObject GetContainerForItemOverride()
        {
            TViewItem checkBoxTreeViewItem = new TViewItem();

            OnNewContainer(checkBoxTreeViewItem);
            return(checkBoxTreeViewItem);
        }
Ejemplo n.º 2
0
 internal void OnNewContainer(TViewItem newContainer)
 {
     newContainer.Checked   -= Checked_EventHandler;
     newContainer.Unchecked -= Unchecked_EventHandler;
     newContainer.Checked   += Checked_EventHandler;
     newContainer.Unchecked += Unchecked_EventHandler;
 }
Ejemplo n.º 3
0
        protected override DependencyObject GetContainerForItemOverride()
        {
            PropertyInfo     parentTreeViewPi       = typeof(TViewItem).GetProperty("ParentTreeView", BindingFlags.Instance | BindingFlags.NonPublic);
            UltimateTreeView parentCheckBoxTreeView = parentTreeViewPi.GetValue(this, null) as UltimateTreeView;
            TViewItem        checkBoxTreeViewItem   = new TViewItem();

            parentCheckBoxTreeView.OnNewContainer(checkBoxTreeViewItem);
            return(checkBoxTreeViewItem);
        }
Ejemplo n.º 4
0
        private void CheckBoxTreeViewItem_Unchecked(object sender, RoutedEventArgs e)
        {
            TViewItem checkBoxTreeViewItem = sender as TViewItem;
            Action    action = () =>
            {
                CheckedItems.Remove((TreeViewItemViewModel)checkBoxTreeViewItem.Header);
            };

            this.Dispatcher.BeginInvoke(action, DispatcherPriority.ContextIdle);
        }
Ejemplo n.º 5
0
        private static Collection <TViewItem> GetAllItemContainers(ItemsControl itemsControl)
        {
            Collection <TViewItem> allItems = new Collection <TViewItem>();

            for (int i = 0; i < itemsControl.Items.Count; i++)
            {
                // try to get the item Container
                TViewItem childItemContainer = itemsControl.ItemContainerGenerator.ContainerFromIndex(i) as TViewItem;
                // the item container maybe null if it is still not generated from the runtime
                if (childItemContainer != null)
                {
                    allItems.Add(childItemContainer);
                }
            }
            return(allItems);
        }
Ejemplo n.º 6
0
        private static ItemsControl GetSelectedTreeViewItemParent(TViewItem item)
        {
            DependencyObject parent = VisualTreeHelper.GetParent(item);

            while (!(parent is TViewItem) && !(parent is UltimateTreeView))
            {
                parent = VisualTreeHelper.GetParent(parent);
            }

            if (parent is UltimateTreeView)
            {
                return(null);
            }

            return(parent as ItemsControl);
        }
Ejemplo n.º 7
0
        private static void CheckedPropertyChanged(DependencyObject source, DependencyPropertyChangedEventArgs e)
        {
            TViewItem checkBoxTreeViewItem = (TViewItem)source;

            if (checkBoxTreeViewItem.IsChecked == true)
            {
                checkBoxTreeViewItem.OnChecked(new RoutedEventArgs(CheckedEvent, checkBoxTreeViewItem));
            }
            else
            if (checkBoxTreeViewItem.IsChecked == false)
            {
                checkBoxTreeViewItem.OnUnchecked(new RoutedEventArgs(UncheckedEvent, checkBoxTreeViewItem));
            }
            else
            {
                checkBoxTreeViewItem.OnIndeterminateChecked(new RoutedEventArgs(IndeterminateCheckedEvent, checkBoxTreeViewItem));
            }

            SetParentCheckedState((TreeViewItemViewModel)checkBoxTreeViewItem.Header);
            SetChildrenCheckedState((TreeViewItemViewModel)checkBoxTreeViewItem.Header);
        }
Ejemplo n.º 8
0
        private static void CheckBoxVisibilityPropertyChanged(DependencyObject source, DependencyPropertyChangedEventArgs e)
        {
            TViewItem checkBoxTreeViewItem = (TViewItem)source;

            checkBoxTreeViewItem.CheckBoxVisibility = (Visibility)(e.NewValue);
        }