Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic How do I override the LoadFromXml method in Diagram? (Read 1145 times)
chowy
Junior Member
**
Offline


I Love MindFusion!

Posts: 72
Joined: May 8th, 2017
How do I override the LoadFromXml method in Diagram?
Dec 6th, 2018 at 3:14am
Print Post  
How do I override the LoadFromXml method in Diagram?
I inherited the diagram, and then I wrote some of my own properties that need to be saved to the xml. But I did not see loadfromxml can be override .
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3147
Joined: Oct 19th, 2005
Re: How do I override the LoadFromXml method in Diagram?
Reply #1 - Dec 6th, 2018 at 4:26pm
Print Post  
This build makes LoadFromXml virtual -
https://mindfusion.eu/_beta/wpfdiag354.zip

Code
Select All
public class MyDiagram : Diagram
{
	public override void SaveToXml(XmlDocument document)
	{
		base.SaveToXml(document);

		var ctx = new XmlPersistContext(
			this, document, XmlPersistContext.LatestFormat);

		ctx.WriteString("test", "Test1", document.DocumentElement);
		ctx.WriteInt(2, "Test2", document.DocumentElement);
	}

	public override void LoadFromXml(XmlDocument document)
	{
		base.LoadFromXml(document);

		var ctx = new XmlPersistContext(
			this, document, XmlPersistContext.LatestFormat);

		var test1 = ctx.ReadString("Test1", document.DocumentElement);
		var test2 = ctx.ReadInt("Test2", document.DocumentElement);

		Debug.WriteLine(test1);
		Debug.WriteLine(test2);
	}
}
 


  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint