Hi,
we are using Silverlight with IronPython, so we generate the data with python.
Is it possible to create a data source with IronPython?
The main problem seems to implement the IEnumerable interface in python.
I'm not an expert on IronPython, so you will have to verify if this would work for you.
According to the IronPython documentation when you interact with .NET and the .NET method expects a different type of data than the one Python provides, automatic conversion will occur. The conversion will be successful when the two types are compatible. Again according to the docs IEnumerable<T> corresponds to a tuple with only elements with type T.
So my guess is that you have to create a DataSource just as you would in a normal SIlverlight application, but at the point where you have to set the ItemsSource to an IEnumerable you will have to set it to a tuple of elements with unanimous type that comes from Python.
I hope this is useful.
All the best,Atanas
thanx for the fast answer.
May be with an example I can show you the problem:
PythonCode:
testDataMulitDimTuple = ( ( '','','','Men','Men','Men','Men','Men','Women','Women','Women','Women','Women' ), ( '','','','Case','Percentage','Mio','Due Percentage','Index','Case','Percentage','Mio','Due Percentage','Index' ), ( 'All','','',58283,100,34.84,49,100,55224,100,35.66,51,100), ( 'All','Age','',4591,8.3,2.88,52,105,5511,7.5,2.69,48,95), ( 'All','Age','14 - 19 years',8211,15,5.23,51,104,9732,13.9,4.97,49,96), ( 'All','Age','20 - 29 years',10215,15.4,5.37,51,103,10081,14.4,5.15,49,97) ) o_flatDataSource = FlatDataSource() o_flatDataSource.ItemsSource = testDataMulitDimTuple dataGrid.DataSource=o_flatDataSource
With this I get an error: ArgumentException: An item with the same key has already been added.
Hi
I am afraid that you can’t set the itemsSource of flatdatasource as multidimensional array. The source should be array from business object. I mean that you should define class and define properties in this class for different elements from data. For example
Public class Data
{
Public string Gender{get; set;}
Public int Age{get;set;}
…..
}
After that create your array from Data and put it to pivot grid
List<Data> list = new List<Data>();
//populate list
o_flatDataSource.ItemsSource = list;
Regards
Todor