This is a migrated thread and some comments may be shown as answers.

Convert string to "Location" type

2 Answers 133 Views
Map
This is a migrated thread and some comments may be shown as answers.
Vuyiswa
Top achievements
Rank 2
Vuyiswa asked on 06 Dec 2011, 07:20 PM
Good Day

i have a service that i previously used the "Location" type , so i could not serialize that type , so i converted it to a string so that i can pass the data from the service to the View. On the other side in the Viewmodel i have a property that is using a "Location" Type and now i am trying to convert the string to location and the Casting does not look like it works.

m.Location = (Telerik.Windows.Controls.Map.Location)lstIncidents[1];


 
Cannot convert type
string to 'Telerik.Windows.Controls.Map.Location' 

2 Answers, 1 is accepted

Sort by
0
Accepted
Andrey
Telerik team
answered on 09 Dec 2011, 09:17 AM
Hi Vuyiswa Maseko,

Casting in code behind don't work for most of the string->object conversions. As for the Location type you should use Parse static method of the Location class:

m.Location = Telerik.Windows.Controls.Map.Location.Parse(lstIncidents[1]);


Best regards,
Andrey Murzov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Vuyiswa
Top achievements
Rank 2
answered on 09 Dec 2011, 12:34 PM
Thanks for the Reply. 

I resolved the problem by using it as "Object" datatype in the Service and when i get to the view i made it a Location Type and it worked. 
Tags
Map
Asked by
Vuyiswa
Top achievements
Rank 2
Answers by
Andrey
Telerik team
Vuyiswa
Top achievements
Rank 2
Share this question
or