private static void CopyDependencyProperties(IVisualElement fromVisual, IVisualElement toVisual) { foreach (var dp in DependencyProperty.GetDependencyPropertiesForType(fromVisual.GetType())) { var val = dp.GetValue(fromVisual); if (val == null) { continue; } dp.SetValueNoTransitions(toVisual, val); } }