Dependency properties are static fields of type DependencyProperty
static IEnumerable<FieldInfo> GetDependencyProperties(Type type) { var dependencyProperties = type.GetFields(BindingFlags.Static | BindingFlags.Public) .Where(p => p.FieldType.Equals(typeof(DependencyProperty))); return dependencyProperties; }
If you want to get the dependency properties of the parents of this control, then you can use the following method:
static IEnumerable<FieldInfo> GetDependencyProperties(Type type) { var properties = type.GetFields(BindingFlags.Static | BindingFlags.Public) .Where(f=>f.FieldType == typeof(DependencyProperty)); if (type.BaseType != null) properties = properties.Union(GetDependencyProperties(type.BaseType)); return properties; }
source share