public static CustomStyle DeserializeStyle(string serialized) { XmlSerializer serializer = new XmlSerializer(typeof(CustomStyle)); StringReader reader = new StringReader(serialized); CustomStyle deser = (CustomStyle)serializer.Deserialize(reader); return(deser); }
public static string SerializeStyle(CustomStyle s) { XmlSerializer serializer = new XmlSerializer(typeof(CustomStyle)); StringWriter writer = new StringWriter(); serializer.Serialize(writer, s); string serialized = writer.ToString(); return(serialized); }
public MainWindow() { InitializeComponent(); CustomStyle s = new CustomStyle(typeof(Button)); s.Setters.Add(new Setter(Button.HeightProperty, 25)); string serializedStyle = StyleSerializer.SerializeStyle(s); mTextBox.Text = serializedStyle; CustomStyle de = StyleSerializer.DeserializeStyle(serializedStyle); }