InitializeComponent(); List<WswModel> ListModel = new List<WswModel>(); string FilePath = @"../../XML/UserAddDelectUpdate.xml"; string FilePathBin = @"wsw.wsw"; XmlDocument XmlDoc = new XmlDocument(); BinaryFormatter binaryFromatter = new BinaryFormatter(); XmlDoc.Load(FilePath); XmlNode XNode = XmlDoc.SelectSingleNode("UserTableXml"); XmlNodeList XNodeList = XNode.ChildNodes; foreach (XmlNode Xnode in XNodeList) { WswModel UserTabel = new WswModel(); UserTabel.UserId = int.Parse(Xnode["UserId"].InnerText); UserTabel.UserName = Xnode["UserName"].InnerText; UserTabel.UserAge = int.Parse(Xnode["UserAge"].InnerText); ListModel.Add(UserTabel); } if (File.Exists(FilePathBin).Equals(false)) { FileStream fs = new FileStream(FilePathBin, FileMode.CreateNew); binaryFromatter.Serialize(fs, ListModel); fs.Close(); } FileStream fileStream = File.Open(FilePathBin, FileMode.Open); List<WswModel> listModel = (List<WswModel>)binaryFromatter.Deserialize(fileStream); Wsw.DataContext = listModel;