2021年5月4日星期二

how to save/load data to n xml file

i'm trying to load and save my data in my datagrid to an xml file using Singleton Design.

i have created

    public class DataProvider  {      private static DataProvider singletonInstance = new DataProvider();      private ObservablePerson Person;        /// <summary>      /// Private constructor      /// </summary>      private DataProvider()      {      }        public static DataProvider GetInstance()      {          if (singletonInstance == null)              singletonInstance = new DataProvider();            return singletonInstance;      }            public bool SaveToXml(List<Person> PersonsList/* add parameters you want to work with */)      {            return false;      }        public List<Person> LoadFromXml(/* add parameters you want*/)      {          return new List<Person>() { new Person() { name= "jhon" } };      }    }  

}

and this is the object i want to save

[Serializable]  public class ObservablePerson : ObservableObject  {      private string _name;      public string name      {          get          {              return _name;          }          set          {              _name= value;              NotifyPropertyChanged();}  

and i also created a view model form from person. what should i do to save those data in my datagrid in a xml file . thanks.

https://stackoverflow.com/questions/67394511/how-to-save-load-data-to-n-xml-file May 05, 2021 at 10:42AM

没有评论:

发表评论