Click here to Skip to main content
14,241,248 members
Rate this:
Please Sign up or sign in to vote.
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 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

Rate this:
Please Sign up or sign in to vote.

Solution 1

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

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

List<control> listControls;</control>


...bind them to your datagrid

datagrid.ItemsSource = listControls;
   

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




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100