private static void PropertyEditor_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e) { FrameworkElement frameworkElement = (FrameworkElement)sender; SceneNodeCategory sceneNodeCategory1 = e.NewValue as SceneNodeCategory; if (sceneNodeCategory1 != null) { PropertyEntry property = frameworkElement.GetValue(SceneNodeCategory.AttachedPropertyEntryProperty) as PropertyEntry; if (property == null) { return; } sceneNodeCategory1.AddAttachedProperty(property); frameworkElement.DataContextChanged -= new DependencyPropertyChangedEventHandler(SceneNodeCategory.PropertyEditor_DataContextChanged); } else { SceneNodeCategory sceneNodeCategory2 = e.OldValue as SceneNodeCategory; if (sceneNodeCategory2 == null) { return; } PropertyEntry property = frameworkElement.GetValue(SceneNodeCategory.AttachedPropertyEntryProperty) as PropertyEntry; if (property == null) { return; } sceneNodeCategory2.RemoveAttachedProperty(property); } }
private static void AttachedPropertyEntryChanged(DependencyObject source, DependencyPropertyChangedEventArgs args) { SceneNodeCategory sceneNodeCategory = source.GetValue(FrameworkElement.DataContextProperty) as SceneNodeCategory; if (sceneNodeCategory != null) { if (args.OldValue != null) { sceneNodeCategory.RemoveAttachedProperty((PropertyEntry)args.OldValue); } if (args.NewValue == null) { return; } sceneNodeCategory.AddAttachedProperty((PropertyEntry)args.NewValue); } else { ((FrameworkElement)source).DataContextChanged += new DependencyPropertyChangedEventHandler(SceneNodeCategory.PropertyEditor_DataContextChanged); } }