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
Thank you for your feedback.
I'm glad I was able to help.
Regards,
Woked great, Thank you for you help!
Hi Michael,
xamDataGrid cannot display the fields the way you're trying to with the current data structure out of the box. What you can do is to change a bit your data object like the following:
public class StatDataSet {
public int IEnumerable<Stats> Stats { get;}
with such a your fields will be auto-generated the way you expect. Find the Attached sample.
Hope this helps,