Implement master detail in one datagrid in wpf

Posted by Archie on Stack Overflow See other posts from Stack Overflow or by Archie
Published on 2010-05-07T05:48:19Z Indexed on 2010/05/07 5:58 UTC
Read the original article Hit count: 348

Filed under:
|
|
|
|

Hello,

I have classes as following:

public class Property  
{
    public string PropertyName { get; set; }
    public int SumSubPropertValue;
    private List<SubProperty> propertyList;

    public void CalculateSumSubPropertValue
    { // implementation}
}

public class SubProperty
{
    public string SubPropertyName { get; set; }
    public int SubPropertyValue { get; set; }
}

I have grouped the rows in datagrid on PropertyName . When the user clicks on PropertyName expnader the columns should display SubPropertyName and SubPropertyValue.

Also SumSubPropertValue should appear in front of PropertyName in the expander header.

My Datagrid is bound to a CollectionViewSource as follows:

CollectionViewSource view = new CollectionViewSource();

view.Source = infoList;

view.GroupDescriptions.Add(new PropertyGroupDescription("PropertyName"));

Where infoList is

ObservableCollection<Property>.

My datagrid colmns look like

<my:DataGrid.Columns>

<my:DataGridTextColumn Header="SubPropertyName" Binding="{Binding SubPropertName}" Width="*"/>

 <my:DataGridTextColumn Header="SubPropertyValue" Binding="{Binding SubPropertyValue}" Width="*"/>

</my:DataGrid.Columns>

Can someone help me with it?

© Stack Overflow or respective owner

Related posts about wpf

Related posts about binding