Hi Mary,
The NameCellContainerStyleKey is actually defined in two places (Common.NameCell.AeroNormalColor.xaml and Common.NameCell.Generic.xaml), since it has two looks. We are consolidating these for the next release, but the overall structure will be the same.
As for you original question, there are several places you could do this. The most straight forward approach would be to build a custom TypeDescriptor that injects that information. Basically, you'd need to:
1. Create a class that derives from ExpandableCollectionConverter (i.e. MyExpandableCollectionConverter)
This is the TypeDescriptor and is responsible for translating the object (in this case a list) to a list of PropertyDescriptors, which are presented by the PropertyGrid.
2. Create a nested class that derives from ExpandableCollectionConverter.ListPropertyDescriptor (i.e. MyExpandableCollectionConverter.MyListPropertyDescriptor)
This wraps each "property" (in this case an item in the list) and provides metadata about the property (i.e. display name, type, value, etc).
3. Override the DisplayName property of MyExpandableCollectionConverter.MyListPropertyDescriptor and return your object's Name property.
Using the ListPropertyDescriptor's List and Index property you can get the associated object, or just call GetValue(null).
4. Create a constructor on MyListPropertyDescriptor that matches the ListPropertyDescriptor's only constructor. Such as:
public MyListPropertyDescriptor(IList list, int index, Type itemType, Attribute[] attributes, bool isReadOnly)
: base(list, index, itemType, attributes, isReadOnly) {
// No-op
}
5. Override the ExpandableCollectionConverter.CreateListPropertyDescriptor method and return a new instance of your MyListPropertyDescriptor and do not call the base implementation.
You can now decorate properties using [TypeDescriptor(typeof(MyExpandableCollectionConverter))] if that property is a list of the type that has the Name property. You could also create a custom list class and decorate that once and it will be picked up for all properties that use it. Such as:
[TypeDescriptor(typeof(MyExpandableCollectionConverter))]
public class MyObjectList : List<MyObject> {
}