[英]Displaying custom name instead of class type in WPF propertygrid
Check out the following link in WPF PropertyGrid documentation . 查看WPF PropertyGrid 文档中的以下链接。 In the image of property grid, notice that the text displayed next to Spouse is
在属性网格的图像中,请注意Spouse旁边显示的文本是
Samples.Modules.PropertyGrid.Views.ExpandableProp
Samples.Modules.PropertyGrid.Views.ExpandableProp
That doesn't look good when you are exposing a PropertyGrid to customers. 当您向客户公开PropertyGrid时,这看起来不太好。 How can I customize what I display there?
如何自定义我在那里显示的内容? Please note that TypeConverter doesn't work for WPF PropertyGrid.
请注意,TypeConverter不适用于WPF PropertyGrid。 I have already tried that :)
我已经尝试过:)
Just override the ToString()
method of Person
class and return whatever you want. 只需覆盖
Person
类的ToString()
方法并返回您想要的任何内容。
In the below code it returns the first name. 在下面的代码中,它返回第一个名称。 With this change it displays the first name of the
Spouse
instead of Samples.Modules.PropertyGrid.Views.ExpandableProp
通过此更改,它显示
Spouse
的第一个名称而不是Samples.Modules.PropertyGrid.Views.ExpandableProp
public override string ToString()
{
return FirstName;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.