Class PropertyGrid
- Namespace
- Myra.Graphics2D.UI.Properties
- Assembly
- Myra.dll
A widget that displays and allows editing of object properties in a grid layout. Uses reflection to discover properties and fields, creates appropriate editors for each type, and organizes them by category with support for nested objects and filtering.
public class PropertyGrid : Widget, IItemWithId, INotifyAttachedPropertyChanged
- Inheritance
-
PropertyGrid
- Implements
- Inherited Members
Constructors
PropertyGrid()
Initializes a new instance of the PropertyGrid class with the default category name.
public PropertyGrid()
PropertyGrid(TreeStyle, string)
Initializes a new instance of the PropertyGrid class with the specified style and category.
public PropertyGrid(TreeStyle style, string category)
Parameters
styleTreeStyleThe tree style to apply to the property grid.
categorystringThe category name for the property grid (typically "Miscellaneous" for root grids).
PropertyGrid(string)
Initializes a new instance of the PropertyGrid class with the specified category using the current stylesheet.
public PropertyGrid(string category)
Parameters
categorystringThe category name for the property grid.
Fields
CustomSetter
Gets or sets a custom setter for applying property values.
[Browsable(false)]
public Func<Record, object, object, bool> CustomSetter
Field Value
CustomValuesProvider
Gets or sets a custom provider for determining the valid values for a property.
[Browsable(false)]
public Func<object, Record, CustomValues> CustomValuesProvider
Field Value
CustomWidgetProvider
Gets or sets a custom provider for creating widgets to edit property values.
[Browsable(false)]
public Func<Record, object, Widget> CustomWidgetProvider
Field Value
Properties
Category
Gets the category name of this property grid.
[Browsable(false)]
public string Category { get; }
Property Value
Filter
Gets or sets the filter string used to filter properties displayed in the grid.
[Browsable(false)]
public string Filter { get; set; }
Property Value
FirstColumnWidth
Gets or sets the width of the first column in the property grid layout.
[Browsable(false)]
public int FirstColumnWidth { get; set; }
Property Value
HorizontalAlignment
Gets or sets the horizontal alignment of the property grid.
public override HorizontalAlignment HorizontalAlignment { get; set; }
Property Value
IgnoreCollections
Gets or sets a value indicating whether collection properties should be ignored when building the property grid.
public bool IgnoreCollections { get; set; }
Property Value
IsEmpty
Gets a value indicating whether the property grid has no child properties.
[Browsable(false)]
public bool IsEmpty { get; }
Property Value
Object
Gets or sets the object being displayed and edited in this property grid.
[Browsable(false)]
public object Object { get; set; }
Property Value
ParentType
Used to determine the attached properties
[Browsable(false)]
public Type ParentType { get; set; }
Property Value
PropertyGridStyle
Gets the tree style used for styling the property grid.
[Browsable(false)]
public TreeStyle PropertyGridStyle { get; }
Property Value
Settings
Gets the settings that control the behavior and appearance of the property grid.
[Browsable(false)]
public PropertyGridSettings Settings { get; }
Property Value
VerticalAlignment
Gets or sets the vertical alignment of the property grid.
public override VerticalAlignment VerticalAlignment { get; set; }
Property Value
Methods
ApplyStyle(WidgetStyle)
Applies the specified widget style to this property grid.
protected override void ApplyStyle(WidgetStyle style)
Parameters
styleWidgetStyleThe widget style to apply.
PassesFilter(string)
Determines whether the specified property name passes the current filter. Uses case-insensitive substring matching.
public bool PassesFilter(string name)
Parameters
namestringThe property name to check.
Returns
- bool
true if the name passes the filter; otherwise, false.
Rebuild()
Rebuilds the property grid based on the current object and settings. Discovers all public properties, fields, and attached properties via reflection, organizes them by category, applies filter, and creates appropriate editor widgets.
public void Rebuild()
Events
ObjectChanged
Occurs when the edited object is changed.
public event MyraEventHandler ObjectChanged
Event Type
PropertyChanged
Occurs when a property value is changed in the grid.
public event MyraEventHandler<GenericEventArgs<string>> PropertyChanged