Click here to Skip to main content
15,881,898 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I'm trying to get a specific DataGrid from an XML file:

          | 01/01/2015 | 02/01/2015 | 03/01/2015
Value 1   |   0.00025  | 0.0000026  |    0.01
.         |..
.         |..
Value n   |..
Average   |..
Expanse   |..


My Xml document is:
XML
<?xml version="1.0" encoding="utf-8"?>
<data>
	<cote>
		<name>XXX</name>
		<filescount>5</filescount>
		<comments>XXX</comments>
		<averageinf>-0.01</averageinf>
		<averagesup>0.01</averagesup>
		<expansemax>0.05</expansemax>
		<control>
			<date>07/08/2014</date>
			<values>
				<value>-0.001</value>
				<value>0.017</value>
				<value>0.034</value>
				<value>0.022</value>
				<value>0.021</value>
			</values>
			<average>0.0186</average>
			<expanse>0.035</expanse>
		</control>
		<control>
			<date>07/08/2014</date>
			<values>
				<value>0.002</value>
				<value>0.001</value>
				<value>0</value>
				<value>0.001</value>
				<value>0</value>
			</values>
			<average>0.0008</average>
			<expanse>0.002</expanse>
		</control>
	</cote>
</data>


For each "control", i want to have a column with his data.

I tried a lot of things, flip datagrid (with layout transform) but without success, there are some datas which not appear when repainting window, add columns manually, but i cannot add rows manually...

Do you have a solution please?

Thanks and Excuse my English
Zwormi
Posted

1 solution

Only a quick suggestion (I don't understand what you tried, or trying to tell - lost in translation?):

Read in your XML to a internal representation of your data.

e.g. something like this

C#
class Control
{
    public DateTime Date { get; set; }
    public double[] Values { get; set; }
    public double Avarage { get; set; }
    public double Expanse { get; set; }
}


...add the instances to a list

C#
List<control> listControls;</control>


...bind them to your datagrid

C#
datagrid.ItemsSource = listControls;
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900