添加PropertyGrid排序功能和枚举元素优先使用Description作为显示#1794
添加PropertyGrid排序功能和枚举元素优先使用Description作为显示#1794katway wants to merge 5 commits intoHandyOrg:masterfrom
Conversation
There was a problem hiding this comment.
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.
src/Shared/HandyControl_Shared/Controls/PropertyGrid/PropertyGrid.cs
Outdated
Show resolved
Hide resolved
src/Shared/HandyControl_Shared/Controls/PropertyGrid/Editors/EnumPropertyEditor.cs
Outdated
Show resolved
Hide resolved
| public static readonly DependencyProperty CategoryOrderProperty = DependencyProperty.Register( | ||
| nameof(CategoryOrder), typeof(int), typeof(PropertyItem), new PropertyMetadata(default(int))); | ||
|
|
There was a problem hiding this comment.
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.
| public static readonly DependencyProperty PropertyOrderProperty = DependencyProperty.Register( | ||
| nameof(PropertyOrder), typeof(int), typeof(PropertyItem), new PropertyMetadata(default(int))); | ||
|
|
There was a problem hiding this comment.
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.
…rid.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…numPropertyEditor.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1.为PropertyGrid添加了Category排序和PropertyItem排序;
2.为EnumPropertyEditor添加优先使用枚举元素的Description作为显示。