I'm trying to store and retrieve data without one application use , means it should refresh instantly on the other list when i redirect , but i'm facing some problem with the saving. would be nice if you could help me out. is the structure alright?
Serialization Exception Type 'System.Collections.Generic.List`1[[Med.sMedication, Med, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]' with data contract name 'ArrayOfsMedication:http://schemas.datacontract.org/2004/07/MedReminder_v1' is not expected. Add any types not known statically to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding them to the list of known types passed to DataContractSerializer.
Class File
public class sMedication
{
public string Name { get; set; }
public string Remarks { get; set; }
public string Dosage { get; set; }
public string Duration { get; set; }
public DateTime StartDate { get; set; }
List<string> medicationItem = new List<string> { "", "", "", "", "" };
public void addtoList()
{
}
public object save(object bigobject)
{
List<Object> Obj = new List<Object>();
Obj.Add(bigobject);
var settings = IsolatedStorageSettings.ApplicationSettings;
settings.Add("Obj", Obj);
settings.Save();
return true;
}
}
Adding code
private void Submit_Clicked(object sender, RoutedEventArgs e)
{
sMedication med = new sMedication();
med.Name = txtName.Text;
med.Dosage = txtDosage.Text;
med.Duration = txtDuration.Text;
med.StartDate = startDate.Value.Value;
List<sMedication> medicationItem = new List<sMedication> { new sMedication { Name = med.Name, Dosage = med.Dosage } };
//{ Name, Remarks, Dosage, Duration, Convert.ToString(StartDate) };
med.save(medicationItem);
NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
}