Convert string to "Location" type

3 posts, 1 answers
  1. Vuyiswa Maseko
    Vuyiswa Maseko avatar
    187 posts
    Member since:
    Jan 2010

    Posted 06 Dec 2011 Link to this post

    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. Answer
    Andrey
    Admin
    Andrey avatar
    1681 posts

    Posted 09 Dec 2011 Link to this post

    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 >>

  3. DevCraft banner
  4. Vuyiswa Maseko
    Vuyiswa Maseko avatar
    187 posts
    Member since:
    Jan 2010

    Posted 09 Dec 2011 Link to this post

    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. 
Back to Top