Table of Contents

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

style TreeStyle

The tree style to apply to the property grid.

category string

The 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

category string

The 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

Func<Record, object, object, bool>

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

Func<object, Record, CustomValues>

CustomWidgetProvider

Gets or sets a custom provider for creating widgets to edit property values.

[Browsable(false)]
public Func<Record, object, Widget> CustomWidgetProvider

Field Value

Func<Record, object, Widget>

Properties

Category

Gets the category name of this property grid.

[Browsable(false)]
public string Category { get; }

Property Value

string

Filter

Gets or sets the filter string used to filter properties displayed in the grid.

[Browsable(false)]
public string Filter { get; set; }

Property Value

string

FirstColumnWidth

Gets or sets the width of the first column in the property grid layout.

[Browsable(false)]
public int FirstColumnWidth { get; set; }

Property Value

int

HorizontalAlignment

Gets or sets the horizontal alignment of the property grid.

public override HorizontalAlignment HorizontalAlignment { get; set; }

Property Value

HorizontalAlignment

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

bool

IsEmpty

Gets a value indicating whether the property grid has no child properties.

[Browsable(false)]
public bool IsEmpty { get; }

Property Value

bool

Object

Gets or sets the object being displayed and edited in this property grid.

[Browsable(false)]
public object Object { get; set; }

Property Value

object

ParentType

Used to determine the attached properties

[Browsable(false)]
public Type ParentType { get; set; }

Property Value

Type

PropertyGridStyle

Gets the tree style used for styling the property grid.

[Browsable(false)]
public TreeStyle PropertyGridStyle { get; }

Property Value

TreeStyle

Settings

Gets the settings that control the behavior and appearance of the property grid.

[Browsable(false)]
public PropertyGridSettings Settings { get; }

Property Value

PropertyGridSettings

VerticalAlignment

Gets or sets the vertical alignment of the property grid.

public override VerticalAlignment VerticalAlignment { get; set; }

Property Value

VerticalAlignment

Methods

ApplyStyle(WidgetStyle)

Applies the specified widget style to this property grid.

protected override void ApplyStyle(WidgetStyle style)

Parameters

style WidgetStyle

The 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

name string

The 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

MyraEventHandler

PropertyChanged

Occurs when a property value is changed in the grid.

public event MyraEventHandler<GenericEventArgs<string>> PropertyChanged

Event Type

MyraEventHandler<GenericEventArgs<string>>