public int IndexFromContainer(UIElement container) { if (container == null) { throw new ArgumentNullException("container"); } ItemContainerGenerator itemContainerGenerator = base.ItemContainerGenerator as ItemContainerGenerator; if (itemContainerGenerator != null && itemContainerGenerator.ItemFromContainer(container) != DependencyProperty.UnsetValue) { object obj = container.ReadLocalValue(IndexForItemContainerProperty); return((obj as int?) ?? (-1)); } return(-1); }
private static void ShowValidationAdornerHelper(DependencyObject targetElement, DependencyObject adornerSite, bool show, bool tryAgain) { UIElement siteUIElement = adornerSite as UIElement; if (siteUIElement != null) { AdornerLayer adornerLayer = AdornerLayer.GetAdornerLayer(siteUIElement); if (adornerLayer == null) { if (tryAgain) { // try again later, perhaps giving layout a chance to create the adorner layer adornerSite.Dispatcher.BeginInvoke(DispatcherPriority.Loaded, new DispatcherOperationCallback(ShowValidationAdornerOperation), new object[] { targetElement, adornerSite, show }); } return; } TemplatedAdorner validationAdorner = siteUIElement.ReadLocalValue(ValidationAdornerProperty) as TemplatedAdorner; if (show && validationAdorner == null) { // get the template from the site, or from the target element ControlTemplate validationTemplate = GetErrorTemplate(siteUIElement); if (validationTemplate == null) { validationTemplate = GetErrorTemplate(targetElement); } if (validationTemplate != null) { validationAdorner = new TemplatedAdorner(siteUIElement, validationTemplate); adornerLayer.Add(validationAdorner); siteUIElement.SetValue(ValidationAdornerProperty, validationAdorner); } } else if (!show && validationAdorner != null) { validationAdorner.ClearChild(); adornerLayer.Remove(validationAdorner); siteUIElement.ClearValue(ValidationAdornerProperty); } } }
public int IndexFromContainer(UIElement container) { if (container == null) { throw new ArgumentNullException("container"); } // The generator is technically not necessary, but it ensures the container was generated and hosted by this panel. var generator = ItemContainerGenerator as ItemContainerGenerator; if (generator != null && generator.ItemFromContainer(container) != DependencyProperty.UnsetValue) { var index = container.ReadLocalValue(IndexForItemContainerProperty); return(index as int? ?? -1); } return(-1); }
// Token: 0x0600597E RID: 22910 RVA: 0x0018B1FC File Offset: 0x001893FC private static void ShowValidationAdornerHelper(DependencyObject targetElement, DependencyObject adornerSite, bool show, bool tryAgain) { UIElement uielement = adornerSite as UIElement; if (uielement != null) { AdornerLayer adornerLayer = AdornerLayer.GetAdornerLayer(uielement); if (adornerLayer == null) { if (tryAgain) { adornerSite.Dispatcher.BeginInvoke(DispatcherPriority.Loaded, new DispatcherOperationCallback(Validation.ShowValidationAdornerOperation), new object[] { targetElement, adornerSite, show }); } return; } TemplatedAdorner templatedAdorner = uielement.ReadLocalValue(Validation.ValidationAdornerProperty) as TemplatedAdorner; if (show && templatedAdorner == null) { ControlTemplate errorTemplate = Validation.GetErrorTemplate(uielement); if (errorTemplate == null) { errorTemplate = Validation.GetErrorTemplate(targetElement); } if (errorTemplate != null) { templatedAdorner = new TemplatedAdorner(uielement, errorTemplate); adornerLayer.Add(templatedAdorner); uielement.SetValue(Validation.ValidationAdornerProperty, templatedAdorner); return; } } else if (!show && templatedAdorner != null) { templatedAdorner.ClearChild(); adornerLayer.Remove(templatedAdorner); uielement.ClearValue(Validation.ValidationAdornerProperty); } } }
public int IndexFromContainer(UIElement container) { if (container == null) { throw new ArgumentNullException("container"); } // The generator is technically not necessary, but it ensures the container was generated and hosted by this panel. var generator = ItemContainerGenerator as ItemContainerGenerator; if (generator != null && generator.ItemFromContainer(container) != DependencyProperty.UnsetValue) { var index = container.ReadLocalValue(IndexForItemContainerProperty); return index as int? ?? -1; } return -1; }
protected sealed override void OnItemsChanged(object sender, ItemsChangedEventArgs args) { if (args == null) { throw new ArgumentNullException("args"); } ItemCollection itemCollection = ItemsOwner?.Items; NotifyCollectionChangedAction action = args.Action; if (action == NotifyCollectionChangedAction.Reset) { OnItemsChanged(itemCollection, new NotifyCollectionChangedEventArgs(action)); } else if (itemCollection != null) { IItemContainerGenerator itemContainerGenerator = sender as IItemContainerGenerator; if (itemContainerGenerator != null) { switch (action) { case NotifyCollectionChangedAction.Add: { int num4 = itemContainerGenerator.IndexFromGeneratorPosition(args.Position); if (args.Position.Offset == 1) { num4 = itemCollection.Count - 1; } VirtualItemsList changedItems2 = new VirtualItemsList(itemCollection, num4, args.ItemCount); if (!IsVirtualizing) { for (int k = num4; k < num4 + args.ItemCount; k++) { RealizeItem(k); } } OnItemsChanged(itemCollection, new NotifyCollectionChangedEventArgs(action, changedItems2, num4)); break; } case NotifyCollectionChangedAction.Remove: { int num5 = itemContainerGenerator.IndexFromGeneratorPosition(args.Position); ArrayList arrayList = new ArrayList(args.ItemCount); for (int l = 0; l < args.ItemUICount; l++) { UIElement uIElement = base.InternalChildren[args.Position.Index + l]; arrayList.Add(ItemFromContainer(uIElement)); if (num5 == -1) { num5 = (int)uIElement.ReadLocalValue(IndexForItemContainerProperty); } uIElement.ClearValue(IndexForItemContainerProperty); } if (args.ItemUICount > 0) { RemoveInternalChildRange(args.Position.Index, args.ItemUICount); } OnItemsChanged(itemCollection, new NotifyCollectionChangedEventArgs(action, arrayList, num5)); break; } case NotifyCollectionChangedAction.Move: { int num2 = -1; int num3 = itemContainerGenerator.IndexFromGeneratorPosition(args.Position); VirtualItemsList changedItems = new VirtualItemsList(itemCollection, num3, args.ItemCount); int itemUICount = args.ItemUICount; if (itemUICount > 0) { UIElement[] array = new UIElement[itemUICount]; for (int i = 0; i < itemUICount; i++) { array[i] = base.InternalChildren[args.OldPosition.Index + i]; if (num2 == -1) { num2 = (int)array[i].ReadLocalValue(IndexForItemContainerProperty); } } RemoveInternalChildRange(args.OldPosition.Index + Math.Min(args.OldPosition.Offset, 1), itemUICount); for (int j = 0; j < itemUICount; j++) { InsertInternalChild(args.Position.Index + j, array[j]); } } OnItemsChanged(itemCollection, new NotifyCollectionChangedEventArgs(action, changedItems, num3, num2)); break; } case NotifyCollectionChangedAction.Replace: { int num = itemContainerGenerator.IndexFromGeneratorPosition(args.Position); VirtualItemsList newItems = new VirtualItemsList(itemCollection, num, args.ItemCount); VirtualItemsList oldItems = new VirtualItemsList(null, num, args.ItemCount); OnItemsChanged(itemCollection, new NotifyCollectionChangedEventArgs(action, newItems, oldItems, num)); break; } } } } base.OnItemsChanged(sender, args); InvalidateReality(); }