Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
40
Members of object inheriting from IEnumerable<T> not being displayed as Fields
posted

I'm having an issue displaying the fields of my XamDataGrid.  Essentially I have two classes like below, and a List<StatDataSet> object.  If I set the datasource to this list, with AutoGenerateFields = True, I get a grid looking like the one in the attached Image1.  I get the Heirachal data that I'm looking for, and the members of the Stats objects are displayed properly however the only Field displayed for the StatDataSet objects is the ToString() stored in a field called Name.  RandomNumber and AnotherRandomNumber are not displayed.  

If I set AutoGenerateFields to false and try to manually add my fields like the xaml code below, I get an exception saying "Field named was not found in data source WpfApplication1.StatDataSet"

In summary, I need to have the hierarchy displaying the data in Stats, as well as Fields displaying the data in each StatDataSet object.

Any help anyone can offer is much appreciated,

<igWPF:XamDataGrid.FieldLayouts>
     <igWPF:FieldLayout Key="{x:Type local:StatDataSet }">
          <igWPF:Field x:Name="RandomNumber" Label="Random Number" />

          <igWPF:Field x:Name="AnotherRandomNumber" Label="Another Random Number" />

     </igWPF:FieldLayout>
</igWPF:XamDataGrid.FieldLayouts>

public class StatDataSet : IEnumerable<Stats>
{

public int RandomNumber { get; set; }

public int AnotherRandomNumber { get; set; }

private List<Stats> Items = null;


public StatDataSet()
{

// initialize Items, populate with x number of Stats objects

// initialize RandomNumber and AnotherRandomNumber

}

// IEnumerable implementation here

}

public class Stats
{

public double Height { get; set; }

public double Weight { get; set; }

public int Age { get; set; }

public Stats()
{

// Initialize members to random values

}

}