I have a TreeViewItem where I am using a TextBlock for the Header property and a custom class as the Tag property. How do I go about creating a copy of the TreeViewItem? I've tried serializing it, but it keeps going into an infinite loop, creates a Stack OverFlow Exception, when it tries to serialize the TreeViewItem, but I can't find out where.
This is the custom class I am using as a Tag property for my TreeViewItem
 [Serializable]
 [XmlRoot(ElementName="TVITagProperty")]
 public class TVITagProperty {
      #region Members
      /// <summary>
      /// Tree Type
      /// </summary>
      public enum TreeType {
           User = 1,
           Other = 2,
      }
      /// <summary>
      /// Tag Property Type
      /// </summary>
      public enum TagType {
           Entity = 1,
           User = 2,
      };
      #endregion
      #region C'tor
      /// <summary>
      /// Public parameterless constructor
      /// </summary>
      public TVITagProperty() { }
      /// <summary>
      /// Create a TreeViewItem Tag Property
      /// </summary>
      /// <param name="type">Type of Tag Property</param>
      /// <param name="value">Value of Tag Property</param>
      public TVITagProperty(TreeType treeType, TagType tagType, string value) {
           ViewType = treeType;
           PropertyType = tagType;
           PropertyValue = value;
           PropertyDirectory = false;
      }
      /// <summary>
      /// Create a TreeViewItem Tag Property
      /// </summary>
      /// <param name="type">Type of Tag Property</param>
      /// <param name="value">Value of Tag Property</param>
      public TVITagProperty(TagType type, long? value) {
           PropertyType = type;
           PropertyValue = value.ToString();
      }
      #endregion
      #region Methods
      /// <summary>
      /// Overloaded Equals method, compares one TVI Tag Property Property Type and Value
      /// </summary>
      /// <param name="obj"></param>
      /// <returns></returns>
      public bool Equals(TVITagProperty obj) {
           if(obj != null) {
                if(obj.PropertyDirectory == true) {
                     if(this.ViewType == obj.ViewType &&
                          this.PropertyType == obj.PropertyType) {
                          return true;
                     }
                }
                else if(this.ViewType == obj.ViewType &&
                     this.PropertyType == obj.PropertyType &&
                     this.PropertyValue.Equals(obj.PropertyValue)) {
                     return true;
                }
           }
           return false;
      }
      /// <summary>
      /// Overrides ToString() and returns Property value
      /// </summary>
      /// <returns></returns>
      public override string ToString() {
           return this.PropertyValue;
      }
      /// <summary>
      /// Returns the Property value as a long
      /// </summary>
      /// <returns></returns>
      public long ToLong() {
           return long.Parse(this.PropertyValue);
      }
      #endregion
      #region Properties
      /// <summary>
      /// Represents the type of TreeView used in the View
      /// </summary>
      [XmlAttribute]
      public TreeType ViewType { get; set; }
      /// <summary>
      /// The type of Property Tag
      /// </summary>
      [XmlAttribute]
      public TagType PropertyType { get; set; }
      /// <summary>
      /// The value of Property Tag
      /// </summary>
      [XmlAttribute]
      public string PropertyValue { get; set; }
      /// <summary>
      /// Defines whether the TVI is an object or directory
      /// </summary>
      [XmlAttribute]
      public bool PropertyDirectory { get; set; }
      #endregion
 }
 
     
     
    