我有一些
WPF控件.例如,TextBox.如何枚举该控件的所有依赖属性(如XAML编辑器那样)?
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; }
在这里找到:http://social.msdn.microsoft.com/Forums/en/wpf/thread/580234cb-e870-4af1-9a91-3e3ba118c89c
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。