public virtual void Unapply(RadElement radElement) { if (cachedChildrenHierarchyByElement.Count == 0) { PrepareCache(radElement); } for (int i = 0; i < this.PropertySettingGroups.Count; i++) { PropertySettingGroup group = this.PropertySettingGroups[i]; for (int k = 0; k < group.Selectors.Count; k++) { IElementSelector selector = group.Selectors[k]; if (selector is HierarchicalSelector) { ((HierarchicalSelector)selector).SetCache(this.cachedChildrenHierarchyByElement); } LinkedList <RadElement> selectedElements = selector.GetSelectedElements(radElement); foreach (RadElement selected in selectedElements) { selector.Unregister(selected, group.PropertySettings); } } } for (int i = 0; i < this.PropertySettingGroups.Count; i++) { PropertySettingGroup group = this.PropertySettingGroups[i]; for (int k = 0; k < group.Selectors.Count; k++) { IElementSelector selector = group.Selectors[k]; LinkedList <RadElement> selectedElements = selector.GetSelectedElements(radElement); foreach (RadElement selected in selectedElements) { PropertyChangeBehaviorCollection propertyChangeBehaviors = selector.GetBehaviors(group); for (int behaviorIndex = 0; behaviorIndex < propertyChangeBehaviors.Count; behaviorIndex++) { PropertyChangeBehavior toRemove = propertyChangeBehaviors[behaviorIndex]; toRemove.BehaviorRemoving(selected); } RoutedEventBehaviorCollection routedEventBehaviors = selector.GetRoutedEventBehaviors(group); for (int eventIndex = 0; eventIndex < routedEventBehaviors.Count; eventIndex++) { RoutedEventBehavior routedEventBehavior = routedEventBehaviors[eventIndex]; routedEventBehavior.BehaviorRemoving(selected); } selected.RemoveRangeBehaviors(propertyChangeBehaviors); selected.RemoveRangeRoutedEventBehaviors(routedEventBehaviors); } } } this.cachedChildrenHierarchyByElement.Clear(); }
public virtual RoutedEventBehaviorCollection GetRoutedEventBehaviors(PropertySettingGroup group) { if (this.createdRoutedEventsBehaviors == null) { this.createdRoutedEventsBehaviors = new RoutedEventBehaviorCollection(); if (this.condition != null) { foreach (RaisedRoutedEvent routedEvent in Condition.AffectedEvents) { RoutedEventStyleBehavior behavior = new RoutedEventStyleBehavior(routedEvent, this, group.PropertySettings); this.createdRoutedEventsBehaviors.Add(behavior); } } } return(this.createdRoutedEventsBehaviors); }