WPF hc:PropertyGrid 嵌套显示

重点:

编写Edit特性即可:

复制代码
public class ParameterEditor : PropertyEditorBase
	{
		public override FrameworkElement CreateElement(PropertyItem propertyItem)
		{
			
			var pg = new PropertyGrid();
            return pg;
		}
        public override DependencyProperty GetDependencyProperty() => PropertyGrid.SelectedObjectProperty;
	}

使用:

复制代码
  private Parameter _parameterInfo = new Parameter();
      
		[Category("参数"), Browsable(true), ReadOnly(false), DisplayName("XX参数"), Editor(typeof(ParameterEditor),typeof(PropertyEditorBase))]
        public Parameter ParameterInfo
		{
	        get => _parameterInfo ;
	        set => Set(ref _parameterInfo , value);
        }

Parameter 类是自定义类,里面可以定义其他想显示的属性。

Editor(typeof(ParameterEditor),typeof(PropertyEditorBase))(这句代码其实很难找,源码并没有直接使用Editor特性,而是动态反射产生的。)

效果:

可以自己定义新样式来优化界面哦

相关推荐
SamChan903 小时前
Python+PyMuPDF提取PDF表格并翻译:表格结构检测与双语重建实战
windows·python·ai·pdf·wpf
SamChan904 小时前
Python+OpenCV检测PDF翻译后排版偏移:像素级格式一致性验证
python·opencv·ai·pdf·wpf
FuckPatience5 小时前
WPF 拿到控件的最初样式,修改获得焦点样式
wpf
主宰者5 小时前
【WPF】MainWindow前添加加载窗口,发现加载过程中有白色无内容窗口闪烁一下的解决方案
wpf
Vae_Mars1 天前
WPF中的ControlTemplate(控件模板)
wpf
SamChan901 天前
Python+ReportLab自动生成PDF翻译质量审计报告:从数据到可视化的完整方案
开发语言·python·ai·pdf·wpf
circuitsosk1 天前
多智能体协同在能源数据分析中的实践:分配-执行-校验闭环架构设计
python·数据分析·wpf·能源·并行计算·多智能体系统·agent协作
weixin199701080162 天前
《大促护航:电商API限流与降级,双11峰值500万调用的架构复盘》(附Python源码)
python·架构·wpf
hh9503 天前
gent Plan x DeepSeek Harness:多 Agent 协作场景下的中央编排实践
人工智能·wpf·adg·火山引擎·agent plan·adg成都社区
Vae_Mars3 天前
WPF中的Lazy<T>使用方法
wpf