private static void OnPropertyChanged(DependencyObject dpo, DependencyPropertyChangedEventArgs e)
{
UIElement uIElement = dpo as UIElement;
if (uIElement == null)
{
return;
}
BehaviorCollection behaviors = Interaction.GetBehaviors(uIElement);
StylizedBehaviorCollection newValue = e.NewValue as StylizedBehaviorCollection;
StylizedBehaviorCollection oldValue = e.OldValue as StylizedBehaviorCollection;
if (newValue == oldValue)
{
return;
}
if (oldValue != null)
{
foreach (Behavior behavior in oldValue)
{
int indexOf = StylizedBehaviors.GetIndexOf(behaviors, behavior);
if (indexOf < 0)
{
continue;
}
behaviors.RemoveAt(indexOf);
}
}
if (newValue != null)
{
foreach (Behavior behavior1 in newValue)
{
if (StylizedBehaviors.GetIndexOf(behaviors, behavior1) >= 0)
{
continue;
}
Behavior behavior2 = (Behavior)behavior1.Clone();
StylizedBehaviors.SetOriginalBehavior(behavior2, behavior1);
behaviors.Add(behavior2);
}
}
}