syncfusion-wpf-propertygrid

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Implementing PropertyGrid

实现PropertyGrid

Guide for implementing Syncfusion® WPF PropertyGrid control — a powerful property inspector for browsing and editing object properties with support for custom editors, category editors, collection editing, grouping, sorting, filtering, and nested properties.
本指南介绍如何实现Syncfusion® WPF PropertyGrid控件——这是一个功能强大的属性检查器,支持浏览和编辑对象属性,还具备自定义编辑器、分类编辑器、集合编辑、分组、排序、筛选以及嵌套属性等功能。

When to Use This Skill

何时使用此技能

Use this skill when you need to:
  • Display object properties for browsing and editing
  • Create property inspectors similar to Visual Studio's Properties window
  • Implement custom value editors for specific property types
  • Group and categorize properties for better organization
  • Edit collection properties with add/remove/edit capabilities
  • Filter and search properties dynamically
  • Support nested properties with expandable property items
  • Customize property display with descriptions, display names, and tooltips
  • Implement design-time editors for visual configuration tools
  • Build configuration panels for application settings
This skill covers the complete PropertyGrid implementation including basic setup, property binding, editors, organization, and advanced customization.
在以下场景中可以使用此技能:
  • 显示对象属性以进行浏览和编辑
  • 创建类似Visual Studio属性窗口的属性检查器
  • 为特定属性类型实现自定义值编辑器
  • 对属性进行分组和分类,提升组织性
  • 编辑集合属性,支持添加/删除/编辑操作
  • 动态筛选和搜索属性
  • 支持嵌套属性,可展开属性项查看详情
  • 自定义属性显示,包括描述、显示名称和工具提示
  • 为可视化配置工具实现设计时编辑器
  • 构建应用程序设置的配置面板
本技能涵盖PropertyGrid的完整实现,包括基础设置、属性绑定、编辑器、组织方式以及高级自定义等内容。

Component Overview

组件概述

Required assemblies:
  • Syncfusion.PropertyGrid.WPF
  • Syncfusion.SfInput.WPF
  • Syncfusion.SfShared.WPF
  • Syncfusion.Shared.WPF
  • Syncfusion.Tools.WPF
XAML namespace:
xml
xmlns:syncfusion="http://schemas.syncfusion.com/wpf"
The PropertyGrid control provides an interface for browsing and editing properties of any object with:
  • Automatic Property Discovery - Reflects properties from any object automatically
  • Custom Value Editors - Assign custom controls for editing specific properties
  • Category Editors - Group related properties with custom editing UI
  • Collection Editor - Built-in dialog for editing collection properties (List, ObservableCollection)
  • Grouping & Sorting - Organize properties by category with multiple sort options
  • Filtering - Hide properties and search with built-in SearchBox
  • Nested Properties - Expand complex objects to show nested properties
  • Blendability - Design-time support in Blend and Visual Studio
  • Theming - Built-in theme support for consistent styling
  • MVVM Support - Full data binding and property change notification
所需程序集:
  • Syncfusion.PropertyGrid.WPF
  • Syncfusion.SfInput.WPF
  • Syncfusion.SfShared.WPF
  • Syncfusion.Shared.WPF
  • Syncfusion.Tools.WPF
XAML命名空间:
xml
xmlns:syncfusion="http://schemas.syncfusion.com/wpf"
PropertyGrid控件提供了一个界面,用于浏览和编辑任意对象的属性,具备以下特性:
  • 自动属性发现 - 自动反射任意对象的属性
  • 自定义值编辑器 - 为特定属性分配自定义控件
  • 分类编辑器 - 使用自定义编辑UI对相关属性进行分组
  • 集合编辑器 - 内置对话框,用于编辑集合属性(List、ObservableCollection)
  • 分组与排序 - 按类别组织属性,支持多种排序选项
  • 筛选功能 - 内置搜索框,可隐藏属性并进行搜索
  • 嵌套属性 - 展开复杂对象以显示嵌套属性
  • Blend兼容性 - 在Blend和Visual Studio中支持设计时操作
  • 主题支持 - 内置主题,确保样式一致性
  • MVVM支持 - 完整的数据绑定和属性变更通知

Control Structure

控件结构

PropertyGrid
├── SearchBox (optional) - Filter properties by name
├── Sort/Group Buttons - Toggle between sorted and categorized views
├── Property List
│   ├── Property Name Column
│   └── Value Editor Column (context-sensitive editors)
└── Description Panel (optional) - Shows property description
PropertyGrid
├── SearchBox(可选)- 按名称筛选属性
├── 排序/分组按钮 - 在排序视图和分类视图之间切换
├── 属性列表
│   ├── 属性名称列
│   └── 值编辑器列(上下文敏感型编辑器)
└── 描述面板(可选)- 显示属性描述

Documentation and Navigation Guide

文档与导航指南

Getting Started

入门指南

📄 Read: references/getting-started.md
  • Installation and assembly deployment
  • Adding PropertyGrid via designer, XAML, and C#
  • Binding with SelectedObject
  • Populating properties automatically
  • Basic configuration and setup
  • Theme support
📄 Read: references/overview.md
  • Control structure and architecture
  • Feature overview and capabilities
  • Use cases and scenarios
  • When to use PropertyGrid
📄 Read: references/property-binding.md
  • SelectedObject binding
  • Data context configuration
  • INotifyPropertyChanged implementation
  • ObservableCollection usage
  • Dynamic property updates
  • Binding multiple objects
📄 阅读: references/getting-started.md
  • 安装和程序集部署
  • 通过设计器、XAML和C#添加PropertyGrid
  • 与SelectedObject绑定
  • 自动填充属性
  • 基础配置和设置
  • 主题支持
📄 阅读: references/overview.md
  • 控件结构和架构
  • 功能概述和能力
  • 使用案例和场景
  • 何时使用PropertyGrid
📄 阅读: references/property-binding.md
  • SelectedObject绑定
  • 数据上下文配置
  • INotifyPropertyChanged实现
  • ObservableCollection的使用
  • 动态属性更新
  • 绑定多个对象

Editors and Customization

编辑器与自定义

📄 Read: references/custom-editors.md
  • Creating custom editors (ITypeEditor interface)
  • Assigning editors via Editor attribute
  • CustomEditorCollection usage
  • Assigning by property name vs property type
  • EditorType vs Editor property
  • Constructor with parameters
  • Attach/Create/Detach methods
  • Custom editor controls
📄 Read: references/category-editors.md
  • CategoryEditor concept
  • Grouping related properties
  • EditorTemplate customization
  • Multiple property categorization
  • Visibility converters
  • Custom category layouts
📄 Read: references/collection-editor.md
  • Editing collection properties (List, ObservableCollection)
  • Add/remove items dialog
  • Editing collection as SelectedObject
  • Nested collection editing
  • Readonly mode configuration
  • CollectionEditorOpening event
  • IList type requirements
📄 Read: references/custom-property-definition.md
  • Manual PropertyItem definition
  • PropertyGridItem configuration
  • AutoGenerateItems property
  • Add/remove items at runtime
  • Custom DisplayName, Description, CategoryName
  • Custom editors and nested properties
  • Description panel templates
📄 阅读: references/custom-editors.md
  • 创建自定义编辑器(ITypeEditor接口)
  • 通过Editor属性分配编辑器
  • CustomEditorCollection的使用
  • 按属性名称vs按属性类型分配
  • EditorType vs Editor属性
  • 带参数的构造函数
  • Attach/Create/Detach方法
  • 自定义编辑器控件
📄 阅读: references/category-editors.md
  • CategoryEditor概念
  • 对相关属性进行分组
  • EditorTemplate自定义
  • 多属性分类
  • 可见性转换器
  • 自定义类别布局
📄 阅读: references/collection-editor.md
  • 编辑集合属性(List、ObservableCollection)
  • 添加/删除项对话框
  • 将集合作为SelectedObject进行编辑
  • 嵌套集合编辑
  • 只读模式配置
  • CollectionEditorOpening事件
  • IList类型要求
📄 阅读: references/custom-property-definition.md
  • 手动定义PropertyItem
  • PropertyGridItem配置
  • AutoGenerateItems属性
  • 在运行时添加/删除项
  • 自定义DisplayName、Description、CategoryName
  • 自定义编辑器和嵌套属性
  • 描述面板模板

Organization Features

组织功能

📄 Read: references/grouping.md
  • EnableGrouping property
  • Grouping by Category attribute
  • Group appearance customization
  • Expand/collapse behavior
  • Group button visibility
📄 Read: references/sorting.md
  • SortDirection property (Ascending, Descending, Null)
  • Sorting properties by name
  • Sorting categories
  • Order attribute for custom ordering
  • ButtonPanelVisibility for sort buttons
  • Disabling sort
📄 Read: references/filtering.md
  • HidePropertiesCollection for hiding properties
  • Browsable attribute (hide with false)
  • Bindable attribute (hide with false)
  • Display.AutoGenerateField attribute
  • AutoGeneratingPropertyGridItem event
  • SearchBox for filtering by name
  • SearchBoxVisibility property
📄 Read: references/nested-properties.md
  • PropertyExpandMode (FlatMode vs NestedMode)
  • NestedPropertyDisplayMode property
  • Expanding complex object properties
  • Update value on lost focus
  • Manual nested property definition
📄 阅读: references/grouping.md
  • EnableGrouping属性
  • 按Category属性分组
  • 分组外观自定义
  • 展开/折叠行为
  • 分组按钮可见性
📄 阅读: references/sorting.md
  • SortDirection属性(Ascending、Descending、Null)
  • 按名称排序属性
  • 对类别进行排序
  • 使用Order属性进行自定义排序
  • 排序按钮的ButtonPanelVisibility
  • 禁用排序
📄 阅读: references/filtering.md
  • 使用HidePropertiesCollection隐藏属性
  • Browsable属性(设置为false时隐藏)
  • Bindable属性(设置为false时隐藏)
  • Display.AutoGenerateField属性
  • AutoGeneratingPropertyGridItem事件
  • 按名称筛选的搜索框
  • SearchBoxVisibility属性
📄 阅读: references/nested-properties.md
  • PropertyExpandMode(FlatMode vs NestedMode)
  • NestedPropertyDisplayMode属性
  • 展开复杂对象属性
  • 失去焦点时更新值
  • 手动定义嵌套属性

Appearance and Behavior

外观与行为

📄 Read: references/appearance.md
  • Visual styling and themes
  • Property name/value appearance
  • Description panel customization
  • DescriptionPanelVisibility property
  • Grid lines and spacing
  • Color customization
📄 Read: references/attached-properties.md
  • Using WPF attached properties
  • PropertyGrid-specific attached properties
  • Configuration examples
📄 Read: references/keyboard-navigation.md
  • Keyboard shortcuts
  • Tab navigation between properties
  • Enter/Escape behavior
  • Focus management
📄 Read: references/localization.md
  • Localization support
  • Resource file configuration
  • Culture-specific strings
  • Customizing built-in text
📄 Read: references/virtualization.md
  • VirtualizingMode property
  • Performance optimization for large property sets
  • Memory management
  • Scrolling behavior
📄 阅读: references/appearance.md
  • 视觉样式和主题
  • 属性名称/值的外观
  • 描述面板自定义
  • DescriptionPanelVisibility属性
  • 网格线和间距
  • 颜色自定义
📄 阅读: references/attached-properties.md
  • 使用WPF附加属性
  • PropertyGrid特定的附加属性
  • 配置示例
📄 阅读: references/keyboard-navigation.md
  • 键盘快捷键
  • 在属性间进行Tab导航
  • Enter/Escape键的行为
  • 焦点管理
📄 阅读: references/localization.md
  • 本地化支持
  • 资源文件配置
  • 特定文化的字符串
  • 自定义内置文本
📄 阅读: references/virtualization.md
  • VirtualizingMode属性
  • 针对大量属性集的性能优化
  • 内存管理
  • 滚动行为

Quick Start Example

快速入门示例

Basic PropertyGrid Setup

基础PropertyGrid设置

xml
<Window x:Class="PropertyGridSample.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:syncfusion="http://schemas.syncfusion.com/wpf">
    <Grid>
        <syncfusion:PropertyGrid Name="propertyGrid1" 
                                 SelectedObject="{Binding SelectedEmployee}"
                                 Width="400" Height="500">
            <syncfusion:PropertyGrid.DataContext>
                <local:ViewModel/>
            </syncfusion:PropertyGrid.DataContext>
        </syncfusion:PropertyGrid>
    </Grid>
</Window>
csharp
// Employee class to be explored in PropertyGrid
public class Employee : INotifyPropertyChanged
{
    private string name;
    public string Name 
    { 
        get => name; 
        set { name = value; OnPropertyChanged(nameof(Name)); } 
    }
    
    [Display(Name = "Employee ID")]
    [Description("Unique identifier for the employee")]
    public string ID { get; set; }
    
    [Category("Personal Info")]
    [DisplayName("Date of Birth")]
    public DateTime DOB { get; set; }
    
    [Category("Personal Info")]
    [Range(18, 65)]
    public int Age { get; set; }
    
    [Browsable(false)] // Hide this property
    public string InternalCode { get; set; }
    
    public event PropertyChangedEventHandler PropertyChanged;
    protected void OnPropertyChanged(string propertyName) =>
        PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}

// ViewModel
public class ViewModel
{
    public object SelectedEmployee { get; set; }
    
    public ViewModel()
    {
        SelectedEmployee = new Employee
        {
            Name = "Johnson",
            Age = 25,
            ID = "EMP001",
            DOB = new DateTime(1999, 5, 15)
        };
    }
}
xml
<Window x:Class="PropertyGridSample.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:syncfusion="http://schemas.syncfusion.com/wpf">
    <Grid>
        <syncfusion:PropertyGrid Name="propertyGrid1" 
                                 SelectedObject="{Binding SelectedEmployee}"
                                 Width="400" Height="500">
            <syncfusion:PropertyGrid.DataContext>
                <local:ViewModel/>
            </syncfusion:PropertyGrid.DataContext>
        </syncfusion:PropertyGrid>
    </Grid>
</Window>
csharp
// 要在PropertyGrid中展示的Employee类
public class Employee : INotifyPropertyChanged
{
    private string name;
    public string Name 
    { 
        get => name; 
        set { name = value; OnPropertyChanged(nameof(Name)); } 
    }
    
    [Display(Name = "Employee ID")]
    [Description("Unique identifier for the employee")]
    public string ID { get; set; }
    
    [Category("Personal Info")]
    [DisplayName("Date of Birth")]
    public DateTime DOB { get; set; }
    
    [Category("Personal Info")]
    [Range(18, 65)]
    public int Age { get; set; }
    
    [Browsable(false)] // 隐藏此属性
    public string InternalCode { get; set; }
    
    public event PropertyChangedEventHandler PropertyChanged;
    protected void OnPropertyChanged(string propertyName) =>
        PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}

// ViewModel
public class ViewModel
{
    public object SelectedEmployee { get; set; }
    
    public ViewModel()
    {
        SelectedEmployee = new Employee
        {
            Name = "Johnson",
            Age = 25,
            ID = "EMP001",
            DOB = new DateTime(1999, 5, 15)
        };
    }
}

Common Patterns

常见模式

Pattern 1: Custom Editor for Email Property

模式1:为Email属性创建自定义编辑器

csharp
// Custom Editor with email validation mask
public class EmailEditor : ITypeEditor
{
    SfMaskedEdit maskedEdit;
    
    public object Create(PropertyInfo propertyInfo)
    {
        maskedEdit = new SfMaskedEdit
        {
            MaskType = MaskType.RegEx,
            Mask = "[A-Za-z0-9._%-]+@[A-Za-z0-9]+.[A-Za-z]{2,3}"
        };
        return maskedEdit;
    }
    
    public void Attach(PropertyViewItem property, PropertyItem info)
    {
        var binding = new Binding("Value")
        {
            Mode = BindingMode.TwoWay,
            Source = info,
            ValidatesOnExceptions = true,
            ValidatesOnDataErrors = true
        };
        BindingOperations.SetBinding(maskedEdit, SfMaskedEdit.ValueProperty, binding);
    }
    
    public void Detach(PropertyViewItem property) { }
}

// Apply to property
public class Employee
{
    [Editor("EmailID", typeof(EmailEditor))]
    public string EmailID { get; set; }
}
csharp
// 带邮箱验证掩码的自定义编辑器
public class EmailEditor : ITypeEditor
{
    SfMaskedEdit maskedEdit;
    
    public object Create(PropertyInfo propertyInfo)
    {
        maskedEdit = new SfMaskedEdit
        {
            MaskType = MaskType.RegEx,
            Mask = "[A-Za-z0-9._%-]+@[A-Za-z0-9]+.[A-Za-z]{2,3}"
        };
        return maskedEdit;
    }
    
    public void Attach(PropertyViewItem property, PropertyItem info)
    {
        var binding = new Binding("Value")
        {
            Mode = BindingMode.TwoWay,
            Source = info,
            ValidatesOnExceptions = true,
            ValidatesOnDataErrors = true
        };
        BindingOperations.SetBinding(maskedEdit, SfMaskedEdit.ValueProperty, binding);
    }
    
    public void Detach(PropertyViewItem property) { }
}

// 应用到属性
public class Employee
{
    [Editor("EmailID", typeof(EmailEditor))]
    public string EmailID { get; set; }
}

Pattern 2: Grouping Properties by Category

模式2:按类别对属性分组

csharp
public class Employee
{
    [Category("Basic Info")]
    public string Name { get; set; }
    
    [Category("Basic Info")]
    public string ID { get; set; }
    
    [Category("Contact Details")]
    public string Email { get; set; }
    
    [Category("Contact Details")]
    public string Phone { get; set; }
}
xml
<syncfusion:PropertyGrid SelectedObject="{Binding Employee}"
                         EnableGrouping="True"/>
csharp
public class Employee
{
    [Category("Basic Info")]
    public string Name { get; set; }
    
    [Category("Basic Info")]
    public string ID { get; set; }
    
    [Category("Contact Details")]
    public string Email { get; set; }
    
    [Category("Contact Details")]
    public string Phone { get; set; }
}
xml
<syncfusion:PropertyGrid SelectedObject="{Binding Employee}"
                         EnableGrouping="True"/>

Pattern 3: Editing Collection Properties

模式3:编辑集合属性

csharp
public class Product
{
    public string ProductName { get; set; }
    
    // Collection property - automatically gets collection editor
    public ObservableCollection<Customer> Customers { get; set; }
    
    public Product()
    {
        Customers = new ObservableCollection<Customer>
        {
            new Customer { ID = 1, Name = "John" },
            new Customer { ID = 2, Name = "Jane" }
        };
    }
}

public class Customer
{
    public int ID { get; set; }
    public string Name { get; set; }
}
csharp
public class Product
{
    public string ProductName { get; set; }
    
    // 集合属性 - 自动获取集合编辑器
    public ObservableCollection<Customer> Customers { get; set; }
    
    public Product()
    {
        Customers = new ObservableCollection<Customer>
        {
            new Customer { ID = 1, Name = "John" },
            new Customer { ID = 2, Name = "Jane" }
        };
    }
}

public class Customer
{
    public int ID { get; set; }
    public string Name { get; set; }
}

Pattern 4: Override Property Items at Runtime

模式4:在运行时覆盖属性项

csharp
private void PropertyGrid_AutoGeneratingPropertyGridItem(
    object sender, AutoGeneratingPropertyGridItemEventArgs e)
{
    // Hide specific properties
    if (e.DisplayName == "InternalCode")
    {
        e.Cancel = true;
    }
    
    // Make property readonly
    if (e.DisplayName == "ID")
    {
        e.ReadOnly = true;
    }
    
    // Change display name
    if (e.DisplayName == "DOB")
    {
        e.DisplayName = "Date of Birth";
    }
    
    // Change category
    if (e.DisplayName == "Age")
    {
        e.Category = "Personal Information";
    }
}
csharp
private void PropertyGrid_AutoGeneratingPropertyGridItem(
    object sender, AutoGeneratingPropertyGridItemEventArgs e)
{
    // 隐藏特定属性
    if (e.DisplayName == "InternalCode")
    {
        e.Cancel = true;
    }
    
    // 将属性设为只读
    if (e.DisplayName == "ID")
    {
        e.ReadOnly = true;
    }
    
    // 更改显示名称
    if (e.DisplayName == "DOB")
    {
        e.DisplayName = "Date of Birth";
    }
    
    // 更改类别
    if (e.DisplayName == "Age")
    {
        e.Category = "Personal Information";
    }
}

Pattern 5: Property Value Changed Notification

模式5:属性值变更通知

csharp
private void PropertyGrid_ValueChanged(object sender, ValueChangedEventArgs e)
{
    var changedProperty = e.Property;
    var oldValue = e.OldValue;
    var newValue = e.NewValue;
    
    // Log the change
    Console.WriteLine($"{changedProperty.Name} changed from {oldValue} to {newValue}");
    
    // React to specific property changes
    if (changedProperty.Name == "Age")
    {
        // Validate or update related properties
    }
}
csharp
private void PropertyGrid_ValueChanged(object sender, ValueChangedEventArgs e)
{
    var changedProperty = e.Property;
    var oldValue = e.OldValue;
    var newValue = e.NewValue;
    
    // 记录变更
    Console.WriteLine($"{changedProperty.Name} changed from {oldValue} to {newValue}");
    
    // 响应特定属性的变更
    if (changedProperty.Name == "Age")
    {
        // 验证或更新相关属性
    }
}

Key Properties

关键属性

Core Properties

核心属性

PropertyTypeDescription
SelectedObjectobjectThe object whose properties are displayed
SelectedObjectsobject[]Multiple objects for common property editing
EnableGroupingboolGroups properties by category
SortDirectionListSortDirection?Sorts properties (Ascending, Descending, null)
PropertyExpandModePropertyExpandModesFlatMode or NestedMode for complex objects
AutoGenerateItemsboolAuto-generates property items (default: true)
属性类型描述
SelectedObjectobject要显示其属性的对象
SelectedObjectsobject[]用于编辑公共属性的多个对象
EnableGroupingbool按类别对属性进行分组
SortDirectionListSortDirection?对属性进行排序(Ascending、Descending、null)
PropertyExpandModePropertyExpandModes复杂对象的显示模式(FlatMode或NestedMode)
AutoGenerateItemsbool自动生成属性项(默认值:true)

UI Configuration

UI配置

PropertyTypeDescription
SearchBoxVisibilityVisibilityShows/hides the search box
ButtonPanelVisibilityVisibilityShows/hides sort/group buttons
DescriptionPanelVisibilityVisibilityShows/hides description panel
EnableToolTipboolEnables tooltips on property items
DisableAnimationOnObjectSelectionboolDisables loading animation
属性类型描述
SearchBoxVisibilityVisibility显示/隐藏搜索框
ButtonPanelVisibilityVisibility显示/隐藏排序/分组按钮
DescriptionPanelVisibilityVisibility显示/隐藏描述面板
EnableToolTipbool启用属性项的工具提示
DisableAnimationOnObjectSelectionbool禁用加载动画

Collections

集合

PropertyTypeDescription
HidePropertiesCollectionObservableCollection<string>Property names to hide
CustomEditorCollectionCustomEditorCollectionCustom editors for properties
ItemsPropertyGridItemCollectionManually defined property items
属性类型描述
HidePropertiesCollectionObservableCollection<string>要隐藏的属性名称
CustomEditorCollectionCustomEditorCollection属性的自定义编辑器
ItemsPropertyGridItemCollection手动定义的属性项

Events

事件

EventDescription
AutoGeneratingPropertyGridItemFired when a property item is being created (can cancel or modify)
ValueChangedFired when a property value changes
SelectedPropertyItemChangedFired when the selected property changes
CollectionEditorOpeningFired before collection editor opens (can cancel or set readonly)
事件描述
AutoGeneratingPropertyGridItem创建属性项时触发(可取消或修改)
ValueChanged属性值变更时触发
SelectedPropertyItemChanged选中的属性变更时触发
CollectionEditorOpening集合编辑器打开前触发(可取消或设置只读)

Common Use Cases

常见使用场景

1. Application Settings Editor

1. 应用程序设置编辑器

Display and edit application configuration with grouped categories (Appearance, Behavior, Performance).
显示并编辑应用程序配置,按类别分组(外观、行为、性能)。

2. Design-Time Property Inspector

2. 设计时属性检查器

Create visual designers for custom controls or components with property editing.
为自定义控件或组件创建可视化设计器,支持属性编辑。

3. Object Inspector in Development Tools

3. 开发工具中的对象检查器

Build debugging or inspection tools to view and modify object properties at runtime.
构建调试或检查工具,在运行时查看和修改对象属性。

4. Dynamic Configuration Panels

4. 动态配置面板

Generate configuration UI automatically from data model classes without manual form design.
无需手动设计表单,从数据模型类自动生成配置UI。

5. Data Entry Forms with Complex Objects

5. 复杂对象的数据输入表单

Display nested object properties with collections, allowing users to edit hierarchical data.
显示嵌套对象属性和集合,允许用户编辑分层数据。

6. Report Parameter Configuration

6. 报表参数配置

Allow users to configure report parameters with appropriate editors for each data type.
允许用户配置报表参数,为每种数据类型提供合适的编辑器。

7. Game/Application Asset Editor

7. 游戏/应用程序资源编辑器

Edit properties of game objects, scenes, or assets with custom editors for vectors, colors, resources.
编辑游戏对象、场景或资源的属性,为向量、颜色、资源等类型提供自定义编辑器。

8. Business Rule Configuration

8. 业务规则配置

Define and edit business rules with property-based configuration and validation.
通过基于属性的配置和验证,定义和编辑业务规则。

Related Components

相关组件

  • PropertyGridItem - Individual property item representation
  • CustomEditor - Custom value editor configuration
  • CategoryEditor - Category-based property grouping
  • Collection Editor - Built-in collection editing dialog
  • PropertyGridItem - 单个属性项的表示
  • CustomEditor - 自定义值编辑器的配置
  • CategoryEditor - 基于类别的属性分组
  • Collection Editor - 内置的集合编辑对话框

Best Practices

最佳实践

  1. Use Attributes for Metadata
    • Apply
      [Category]
      ,
      [Description]
      ,
      [DisplayName]
      attributes to properties
    • Use
      [Browsable(false)]
      to hide properties instead of code-based filtering
  2. Implement INotifyPropertyChanged
    • Ensure your data objects implement property change notification
    • Use
      ObservableCollection
      for collection properties
  3. Custom Editors for Complex Types
    • Create custom editors for types that don't have suitable default editors
    • Consider user experience when designing custom editor UI
  4. Performance with Large Objects
    • Use virtualization for objects with many properties
    • Consider lazy loading for nested properties
    • Filter unnecessary properties early
  5. Validation
    • Use data annotations for validation (
      [Required]
      ,
      [Range]
      , etc.)
    • Handle validation errors gracefully in custom editors
  6. Accessibility
    • Ensure custom editors support keyboard navigation
    • Provide meaningful descriptions for screen readers
    • Test with high contrast themes
  1. 使用属性添加元数据
    • 为属性应用
      [Category]
      [Description]
      [DisplayName]
      属性
    • 使用
      [Browsable(false)]
      隐藏属性,而非基于代码的筛选
  2. 实现INotifyPropertyChanged
    • 确保数据对象实现属性变更通知
    • 对集合属性使用
      ObservableCollection
  3. 为复杂类型创建自定义编辑器
    • 为没有合适默认编辑器的类型创建自定义编辑器
    • 设计自定义编辑器UI时考虑用户体验
  4. 处理大型对象的性能问题
    • 对拥有大量属性的对象使用虚拟化
    • 考虑对嵌套属性进行懒加载
    • 尽早筛选不必要的属性
  5. 验证
    • 使用数据注解进行验证(
      [Required]
      [Range]
      等)
    • 在自定义编辑器中优雅处理验证错误
  6. 可访问性
    • 确保自定义编辑器支持键盘导航
    • 为屏幕阅读器提供有意义的描述
    • 使用高对比度主题进行测试

Troubleshooting

故障排除

Properties Not Showing

属性未显示

  • Verify
    [Browsable]
    attribute is not false
  • Check if property is in
    HidePropertiesCollection
  • Ensure property has public getter
  • Verify
    AutoGenerateItems
    is true
  • 验证
    [Browsable]
    属性未设置为false
  • 检查属性是否在
    HidePropertiesCollection
  • 确保属性有公共的getter
  • 验证
    AutoGenerateItems
    设为true

Custom Editor Not Applied

自定义编辑器未生效

  • Check editor is properly registered in
    CustomEditorCollection
  • Verify property name/type matches
  • Ensure editor implements
    ITypeEditor
    correctly
  • Check
    Create
    method returns valid control
  • 检查编辑器是否已正确注册到
    CustomEditorCollection
  • 验证属性名称/类型是否匹配
  • 确保编辑器正确实现了
    ITypeEditor
  • 检查
    Create
    方法是否返回有效的控件

Collection Editor Not Opening

集合编辑器无法打开

  • Verify collection type derives from
    IList
  • Ensure collection property has setter
  • Check collection type has parameterless constructor
  • Verify
    CollectionEditorOpening
    event doesn't cancel
  • 验证集合类型派生自
    IList
  • 确保集合属性有setter
  • 检查集合类型有无参构造函数
  • 验证
    CollectionEditorOpening
    事件未取消操作

Performance Issues

性能问题

  • Enable virtualization for large property sets
  • Reduce nested property depth
  • Filter unnecessary properties
  • Consider manual property definition instead of auto-generation

Next Steps: Navigate to specific reference documents above based on your implementation needs. Start with getting-started.md for initial setup, then explore editors and organization features as needed.
  • 为大型属性集启用虚拟化
  • 减少嵌套属性的深度
  • 筛选不必要的属性
  • 考虑使用手动属性定义替代自动生成

下一步: 根据你的实现需求,导航至上述特定参考文档。从getting-started.md开始进行初始设置,然后根据需要探索编辑器和组织功能。