public static void RemoveObjectNames(DrawingGroup drawingGroup) { if (drawingGroup.GetValue(FrameworkElement.NameProperty) != null) drawingGroup.SetValue(FrameworkElement.NameProperty, null); foreach (var child in drawingGroup.Children.OfType<DependencyObject>()) { if (child.GetValue(FrameworkElement.NameProperty) != null) child.SetValue(FrameworkElement.NameProperty, null); if (child is DrawingGroup) RemoveObjectNames(child as DrawingGroup); } }