From 4ee183976bb9ac8bc1a9700d26a0a6e9103a6378 Mon Sep 17 00:00:00 2001 From: brianlagunas_cp Date: Mon, 18 Apr 2011 19:55:07 +0000 Subject: [PATCH] PropertyGrid EnumComboBoxEditor: removed values with Browsable attribute --- .../Implementation/Editors/EnumComboBoxEditor.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/Editors/EnumComboBoxEditor.cs b/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/Editors/EnumComboBoxEditor.cs index fb5def1a..c79a0e29 100644 --- a/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/Editors/EnumComboBoxEditor.cs +++ b/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/Editors/EnumComboBoxEditor.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Reflection; +using System.ComponentModel; namespace Microsoft.Windows.Controls.PropertyGrid.Editors { @@ -14,11 +15,20 @@ namespace Microsoft.Windows.Controls.PropertyGrid.Editors private static object[] GetValues(Type enumType) { - List values = new List(); + List values = new List(); var fields = enumType.GetFields().Where(x => x.IsLiteral); foreach (FieldInfo field in fields) { + // Get array of BrowsableAttribute attributes + object[] attrs = field.GetCustomAttributes(typeof(BrowsableAttribute), false); + if (attrs.Length == 1) + { + // If attribute exists and its value is false continue to the next field... + BrowsableAttribute brAttr = (BrowsableAttribute)attrs[0]; + if (brAttr.Browsable == false) continue; + } + values.Add(field.GetValue(enumType)); }