views:

36

answers:

1

Is there a way to pass an array or List<> from the aspx.cs to xaml.cs?

+2  A: 

the only way to pass data from your aspx hosting the control to your silverlight control is using InitParams which is a dictionary. try concating your string array using some predefied separator which you set on the InitParams and split again in the silverlight control.

update

string data = string.Join("[SEP]", strList);
string InitParams = "data=" + data;

you can embed this InitParams string into your object tag. pass this via InitParams. in your silverlight application

string[] data = e.InitParams["data"].Split("[SEP]");
Vinay B R
@vinay i figured out how to pass single variables then parse them on the xaml.cs side, but how do you send a list/array or object?
cfarm54
i have updated my answer
Vinay B R
@vinay awesome i'll try it out. I'm assuming that string.Join works when you pass in a List<double> also?
cfarm54
Do you know how to do this with a List<double>?
cfarm54
InitParams can only take strings so might have to convert your List<double> to list<string> in aspx and convert it back in xaml
Vinay B R
@vinay interesting. why is your second portion of code in an event handler? if so, what is the event handler you're calling? thx
cfarm54
e is application start up event args in your silverlight application
Vinay B R