Welcome to the Xceed Community | Help
Community Search  
More Search Options

DataGridCollectionViewSource Grouping with custom objects

Sort Posts: Previous Next
  •  12-21-2011, 1:39 PM Post no. 31487

    DataGridCollectionViewSource Grouping with custom objects

    Dear Forum,

    I have a grid binding to the followinf DataGridCollectionViewSource:

    <xcdg:DataGridCollectionViewSource x:Key="ReportDataDGCVSReference" Source="{Binding ReportData}">
    <xcdg:DataGridCollectionViewSource.GroupDescriptions>
    <xcdg:DataGridGroupDescription PropertyName="PositionType" />
    </xcdg:DataGridCollectionViewSource.GroupDescriptions>
    </xcdg:DataGridCollectionViewSource>

    PositionType is actually an object of a class I have written and it has a property string PositionTypeVal.

    I use a datatemplate to render the class and it does ok but the grouping is not working as expected because PositionType group each row in a separate group. This is because each row has a different instance of PositionType even if PositionTypeVal is the same. Any way to look at PositionTypeVal property instead of the object itself to do the grouping?

    Unfortunatelly those objects comes from an external dll and are different instances even if PositionTypeVal property is the same.

    Thanks!

  •  12-22-2011, 11:38 AM Post no. 31490 in reply to 31487

    Re: DataGridCollectionViewSource Grouping with custom objects

    Thanks to Vanguard support I have a solution to this:

    <xcdg:DataGridCollectionViewSource x:Key="ReportDataDGCVSReference" Source="{Binding ReportData}">
    <xcdg:DataGridCollectionViewSource.GroupDescriptions>
    <xcdg:DataGridGroupDescription PropertyName="PositionType" />
    </xcdg:DataGridCollectionViewSource.GroupDescriptions>
    <xcdg:DataGridCollectionViewSource.ItemProperties>
    <xcdg:DataGridItemProperty Name="PositionType" DataType="{x:Type system:String}" ValuePath="PositionType.PositionTypeVal"/>
    </xcdg:DataGridCollectionViewSource.ItemProperties>
    </xcdg:DataGridCollectionViewSource>

    Thanks!

View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2011 Xceed Software Inc.