I have some WPF control. For example, TextBox. How to enumerate all dependency properties of that control (like XAML editor does)?
public IList<DependencyProperty> GetAttachedProperties(DependencyObject obj) { List<DependencyProperty> result = new List<DependencyProperty>(); foreach (PropertyDescriptor pd in TypeDescriptor.GetProperties(obj, new Attribute[] { new PropertyFilterAttribute(PropertyFilterOptions.All) })) { DependencyPropertyDescriptor dpd = DependencyPropertyDescriptor.FromProperty(pd); if (dpd != null) { result.Add(dpd.DependencyProperty); } } return result; }
Found here: http://social.msdn.microsoft.com/Forums/en/wpf/thread/580234cb-e870-4af1-9a91-3e3ba118c89c
2.1m questions
2.1m answers
60 comments
57.0k users