protected override DependencyObject GetContainerForItemOverride() { TViewItem checkBoxTreeViewItem = new TViewItem(); OnNewContainer(checkBoxTreeViewItem); return(checkBoxTreeViewItem); }
internal void OnNewContainer(TViewItem newContainer) { newContainer.Checked -= Checked_EventHandler; newContainer.Unchecked -= Unchecked_EventHandler; newContainer.Checked += Checked_EventHandler; newContainer.Unchecked += Unchecked_EventHandler; }
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); }
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); }
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); }
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); }
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); }
private static void CheckBoxVisibilityPropertyChanged(DependencyObject source, DependencyPropertyChangedEventArgs e) { TViewItem checkBoxTreeViewItem = (TViewItem)source; checkBoxTreeViewItem.CheckBoxVisibility = (Visibility)(e.NewValue); }