I have a collection of objects that has a nested collection of objects . I want the nested collection in my datagrid to display inside a nested datagrid horizontally, if this is at all possible. Here are my classes:
public class Details
{
public string Customer {get;set;}
public List<Type> Types { get; set;}
}
public class Type
{
public string typeId{get;set;}
}
Of course they are really ObservableCollections and I im开发者_运维百科plement the INotifyPropertyChange, but this is just a quick skeleton of my classes to get the main point out there.
It would be nice if I could it to display like this:
Details Customer
Types[0] typeId Types[1] typeId .... Types[n] typeId
I hope this make sense. Basically for the type I want the id displayed horizontally. So how could I get just the Types collection to display as columns and not rows? I essentially want to add another collection to Type and nest datagrids to that one, but those need not be horizontal, just this one. Any help would be greatly appreciated. Thanks in advance.
The RowDetailsTemplate might work here:
<DataGrid>
<DataGrid.RowDetailsTemplate>
<DataTemplate>
<xzy />
</DataTemplate>
</DataGrid.RowDetailsTemplate>
</DataGrid>
The <xyz />
would be the part where you display your Types horizontally. Depending on your needs, you can either make a UserControl (create a public IEnumerable<Type> Types { get; set; }
, bind your Types
member to it and implement the display logic there), a StackPanel or a simple TextBlock where you concatenate your type-names.
精彩评论