Of course I have searched everywhere on the web but I can't find the solution of my problem.
My problem
I have Patient Class that contains a list of Audiograms (Audiogramm Class). Actually, I can display list of Patients in the DataGrid. But I want to display, for each patient, his Audiogram in a DataGrid (WPF).
class Patient
{
public Patient(string patientid, string genre, string createdate)
{
this.patientID = patientid;
this.genre = genre;
this.createDate = createdate;
audiogram = new List<Audiogram>();
}
public string patientID { get; set; }
public string genre{ get; set; }
public string createDate { get; set; }
public List<Audiogram> audiogram { get; set; }
}
class Audiogram
{
public Audiogram(string typeData, string actionDate)
{
this.typeData = typeData;
this.actionData = actionData;
}
public string typeData { get; set; }
public string actionData { get; set; }
}
XmlNodeList nodeList = root.SelectNodes("/pt:NOAH_Patients_Export/pt:Patient/pt:Patient", nsmgr);
foreach (XmlNode node in nodeList)
{
XmlNodeList nodeListAudio = node.SelectNodes("//pt:Actions", nsmgr);
Patient patient = new Patient(node["pt:NOAHPatientId"].InnerText, node["pt:Gender"].InnerText, node["pt:CreateDate"].InnerText);
foreach (XmlNode nodeAudio in nodeListAudio)
{
Audiogram audiogramme = new Audiogram(nodeAudio["pt:TypeOfData"].InnerText, nodeAudio["pt:ActionDate"].InnerText);
patient.audiogram.Add(audiogramme);
}
listPatient.Add(patient);
}
dataGrid_XML.ItemsSource = listPatient;
<DataGrid x:Name="dataGrid_XML" AutoGenerateColumns="false" ItemsSource="{Binding Patient}"> <DataGrid.Columns> <DataGridTextColumn Binding="{Binding patientID}" Header="ID Patient"/> <DataGridTextColumn Binding="{Binding genre}" Header="Genre"/> <DataGridTextColumn Binding="{Binding createDate}" Header="Date création"/> <DataGridTextColumn Binding="{Binding audiogram.typeData}" Header="Type de données"/> <DataGridTextColumn Binding="{Binding audiogram.actionData}" Header="Date de dernière action"/> </DataGrid.Columns> </DataGrid>