private static DependencyPropertySet FindProperties(Type type, bool declaredOnly) { var dict = Util .GetTypeChain(type, declaredOnly) .Select(t => DependencyProperty.GetDeclaredProperties(t)) .Where(p => p != null) .SelectMany(p => p) .ToDictionary(p => p.Key, p => p.Value, StringComparer.OrdinalIgnoreCase); return(new DependencyPropertySet(type, dict)); }