1 <Grid Name="UpConfigeGrid" > 2 <WindowsFormsHost Name="WinForm" Background="White"> 3 <Lee:PropertyGrid Name="XmlConfigePGrid"> 4 </Lee:PropertyGrid> 5 </WindowsFormsHost> 6 </Grid>
可参考 http://msdn.microsoft.com/zh-tw/library/system.windows.forms.propertygrid.aspx
也给你一个例子:
首先定义一个类
using System;
using System.ComponentModel;
namespace PropertyGridDemo
{
[DefaultPropertyAttribute("Name")]
public class Customer
{
private string name;
private string email;
private string mark;
[CategoryAttribute("用户信息"), DescriptionAttribute("设置消费者姓名")]
public string Name
{
get
{
return name;
}
set
{
name = value;
}
}
[CategoryAttribute("用户信息"), DescriptionAttribute("设置消费者Email地址")]
public string Email
{
get
{
return email;
}
set
{
email = value;
}
}
[CategoryAttribute("备注"), DescriptionAttribute("备注信息")]
public string Mark
{
get
{
return mark;
}
set
{
mark = value;
}
}
public Customer()
{
}
}
}
然后调用
Customer customer = new Customer();
customer.Name = "张三";
customer.Email = "zhangsan@sina.com";
propertyGrid1.SelectedObject = customer;
当然你也可以用List<Customer>作为selectobject