serialization is nothing with wpf or mvvm (I assume your question is about serialization in general). The following is not the only way, but if you want to serialize an object:
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;
namespace ConsoleApplication1
{
[Serializable]
public class AClass
{
public string AProperty { get; set; }
public void SerializeMe(string intoFile)
{
using (var fs = new StreamWriter(intoFile))
{
var ser = new XmlSerializer(typeof(AClass));
ser.Serialize(fs, this);
}
}
public static AClass Deserialize(string fromFile)
{
AClass instance = null;
using (var fs = new StreamReader(fromFile))
{
var ser = new XmlSerializer(typeof(AClass));
instance = (AClass)ser.Deserialize(fs);
}
return instance;
}
}
}
use it as:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Test("test.xml");
}
static void Test(string xmlFile)
{
AClass a = new AClass() { AProperty = "prop value" };
a.SerializeMe(xmlFile);
var b = AClass.Deserialize(xmlFile);
}
}
}
more example:
http://msdn.microsoft.com/en-us/library/58a18dwa%28v=vs.110%29.aspx