In a MVVM design pattern, we are creating a ViewModel inheriting from CustomTypeDescriptor.In doing so, we need to known which types are natively supported by the xamPropertyGrid in order to default unsupported types to a String.From my understanding, PropertyGridEditorDefinitionCollection would just do that but since we are in a MVVM design pattern the xamPropertyGrid is not instanciated when we are creating our ViewModel.
Is there some static class information that could be used?
Thank you Andrew, clear enough.
Have a great day.
JMD
Hello Jean,
The 'natively' supported types to the XamPropertyGrid are the .NET Primitive types and the types that are listed below:
DateTimeDateTime?ColorBrushboolenums that support StandardValuesFontFamilyFontWeightFontStyleFontStretchstringProperties of type ICollection, IList, IEnumerable
Each of these types has a different editor assigned to it. I will list these "default editor definitions" below by the types that are assigned to it. If the editor definition is very basic, I will simply list the control that corresponds to that type.
.NET Primitives and String: A TextBox is used as the default editor for these types.
Bool: A Checkbox is used as the default editor for bool.
FontFamily, FontStretch, FontStyle, FontWeight, Enum: A ComboBox is used for the default editor for these types. In the drop-down, the corresponding enum, FontFamily, FontStretch, FontStyle, or FontWeight values will be present.
DateTime / DateTime?: The Infragistics XamDateTimeInput is used as the default editor for DateTime and nullable DateTime. You can read further about the XamDateTimeInput here: https://www.infragistics.com/help/wpf/xamdatetimeinput.
Color: The Infragistics XamColorPicker is used as the default editor for the Color type. You can read further about the XamColorPicker here: https://www.infragistics.com/help/wpf/xamcolorpicker.
Brush: For Brushes, a custom editor named the PropertyGridBrushEditorControl is used. This is a custom control that allows you to modify the ARGB values of a particular brush and assign it to a particular Field on your data item. If you would like to see more, you can find the default style for this PropertyGridBrushEditorControl in the generic.shared.xaml file commonly found at the following directory:
C:\Program Files (x86)\Infragistics\\WPF\DefaultStyles\PropertyGrid
IList / ICollection / IEnumerable: Lists and other ICollection/IList/IEnumerable derivations use a PropertyGridListEditorControl. Essentially, this is a control that is not really "editable," but allows expansion and viewing of the underlying items to the collection tied to a property on your object. Each of the child objects will be represented as an index (e.g. [0], [1], etc.). These child objects are expandable as well, allowing you to view the properties attached to your child objects to that particular IList/ICollection/IEnumerable.
I have attached a sample project to demonstrate each of the above-mentioned editors in action. I hope this helps.
Please let me know if you have any other questions or concerns on this matter.
Sincerely,AndrewAssociate Developer