Hello,
I want to display collection property on PropertyGrid.
I understand that I should use TypeDescriptorFactory, but I'm not sure how to display collection property.
Would you please tell me how to do it?
<grids:PropertyGrid DataObject="{Binding Properties}" />
DataContext is :
public class MainWindowViewModel
{
public List<PropertyItem> Properties { get; } = new List<PropertyItem>();
public MainWindowViewModel()
{
Properties.Add(new PropertyItem(){Name = "CustomerName", Value = "AAAA"});
Properties.Add(new PropertyItem(){Name = "Country", Value = "US"});
var phoneNumbersProperty = new PropertyItem(){Name = "Phone numbers"};
phoneNumbersProperty.Children.Add(new PropertyItem(){Name = "Fax", Value = "491-294-1356"});
phoneNumbersProperty.Children.Add(new PropertyItem(){Name = "Voice", Value = "491-198-1285"});
Properties.Add(phoneNumbersProperty);
}
public class PropertyItem
{
// PropertyName
public string Name { get; set; }
// PropertyValue
public object Value { get; set; }
// Children properties (Expandable items)
public List<PropertyItem> Children { get; } = new List<PropertyItem>();
}
}
I want to display it in the same way as lower PropertyGrid of "Custom Data Factory" sample.