How to enumerate all dependency properties of control?

前端 未结 5 1812
名媛妹妹
名媛妹妹 2020-12-01 21:17

I have some WPF control. For example, TextBox. How to enumerate all dependency properties of that control (like XAML editor does)?

5条回答
  •  广开言路
    2020-12-01 22:09

    Try

            var fieldInfos = typeof(TextBox).GetFields( BindingFlags.Public | BindingFlags.Static).Where(x=>x.FieldType == typeof(DependencyProperty));
            foreach (var fieldInfo in fieldInfos)
            {
                Console.WriteLine(fieldInfo.Name);
            }
    

提交回复
热议问题