Skip to content

添加PropertyGrid排序功能和枚举元素优先使用Description作为显示#1794

Open
katway wants to merge 5 commits intoHandyOrg:masterfrom
katway:master
Open

添加PropertyGrid排序功能和枚举元素优先使用Description作为显示#1794
katway wants to merge 5 commits intoHandyOrg:masterfrom
katway:master

Conversation

@katway
Copy link
Copy Markdown

@katway katway commented Mar 31, 2026

1.为PropertyGrid添加了Category排序和PropertyItem排序;
2.为EnumPropertyEditor添加优先使用枚举元素的Description作为显示。

Copilot AI review requested due to automatic review settings March 31, 2026 08:48
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

该 PR 为 HandyControl 的 PropertyGrid 增加可配置的分类/属性排序能力,并让枚举编辑器在下拉展示时优先使用枚举字段的 DescriptionAttribute 文本,从而提升 PropertyGrid 的可读性与可控性(尤其在 Demo 中更直观展示排序效果)。

Changes:

  • PropertyGrid 新增 CategoryOrder / PropertyOrder 两个依赖属性,并在按分类排序时引入对应的排序权重。
  • PropertyItem 增加 CategoryOrder / PropertyOrder 字段(依赖属性),用于承载排序权重。
  • EnumPropertyEditor 改为显示枚举字段的 DescriptionAttribute(若存在),否则回退到枚举名。

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/Shared/HandyControlDemo_Shared/UserControl/Controls/PropertyGridDemo.xaml Demo 中配置 CategoryOrder/PropertyOrder,用于演示新的排序能力
src/Shared/HandyControlDemo_Shared/Data/Model/PropertyGridDemoModel.cs 调整 Demo 分类并为枚举值补充 Description 以演示新显示逻辑
src/Shared/HandyControl_Shared/Controls/PropertyGrid/PropertyItem.cs 新增排序权重依赖属性,供 PropertyGrid 排序使用
src/Shared/HandyControl_Shared/Controls/PropertyGrid/PropertyGrid.cs 新增排序配置入口并在分类排序时应用排序权重
src/Shared/HandyControl_Shared/Controls/PropertyGrid/Editors/EnumPropertyEditor.cs 枚举下拉项显示优先使用 DescriptionAttribute

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +92 to +94
public static readonly DependencyProperty CategoryOrderProperty = DependencyProperty.Register(
nameof(CategoryOrder), typeof(int), typeof(PropertyItem), new PropertyMetadata(default(int)));

Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency with the rest of the codebase (many int dependency properties use ValueBoxes.Int0Box, e.g. PasswordBoxAttach.PasswordLengthProperty), consider using ValueBoxes.Int0Box as the default metadata value here instead of default(int) to reduce boxing/allocations.

Copilot uses AI. Check for mistakes.
Comment on lines +101 to +103
public static readonly DependencyProperty PropertyOrderProperty = DependencyProperty.Register(
nameof(PropertyOrder), typeof(int), typeof(PropertyItem), new PropertyMetadata(default(int)));

Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency with the rest of the codebase (many int dependency properties use ValueBoxes.Int0Box), consider using ValueBoxes.Int0Box as the default metadata value here instead of default(int) to reduce boxing/allocations.

Copilot uses AI. Check for mistakes.
katway and others added 2 commits March 31, 2026 18:15
…rid.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…numPropertyEditor.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants