Unplanned
Last Updated: 24 Nov 2021 11:57 by ADMIN
Ken
Created on: 24 Nov 2021 11:46
Category: TreeView
Type: Bug Report
0
RadTreeView: Error occurs when loading xml content

Please use the attached sample project.

Result in 2021.1.326:

Result in 2021.2.511

Attached Files:
1 comment
ADMIN
Dess | Tech Support Engineer, Principal
Posted on: 24 Nov 2021 11:57

Hello, Ken,

Thank you for reporting this issue. We will treat it with highest priority. Meanwhile, feel free to use the following workaround:

        public RadForm1()
        {
            InitializeComponent();
            // this.radTreeView1.TreeViewXml = treeViewXML;

            ((CustomTreeView)this.radTreeView1).LoadXMLContent(treeViewXML);
        } 

        public class CustomTreeView : RadTreeView
        {
            public override string ThemeClassName
            {
                get
                {
                    return typeof(RadTreeView).FullName;
                }
            }
            protected override void LoadXMLWithReader(XmlReader reader, params Type[] extraTypes)
            {
                base.LoadXMLWithReader(reader, extraTypes);
            }

            public void LoadXMLContent(string xmlContent)
            {
                using (StringReader reader = new StringReader(xmlContent) {   })
                {
                    LoadXMLWithTextReader(reader);
                }
            }
            private void LoadXMLWithTextReader(TextReader reader, params Type[] extraTypes)
            {
                XmlTreeSerializer serializer = null;

                if (extraTypes == null || extraTypes.Length == 0)
                {
                    serializer = new XmlTreeSerializer(typeof(XmlTreeView));
                }
                else
                {
                    serializer = new XmlTreeSerializer(typeof(XmlTreeView), extraTypes);
                }

                XmlTreeView xmlTreeView = serializer.Deserialize(reader) as XmlTreeView;
                xmlTreeView.Deserialize(this);
            }
        }

        internal class XmlTreeSerializer : XmlSerializer
        {
            #region Constructors

            public XmlTreeSerializer(Type type, Type[] extraType)
                : base(type, extraType)
            {
                this.UnknownAttribute += new XmlAttributeEventHandler(XmlTreeSerializer_UnknownAttribute);
            }

            public XmlTreeSerializer(Type type)
                : base(type)
            {
                this.UnknownAttribute += new XmlAttributeEventHandler(XmlTreeSerializer_UnknownAttribute);
            }

            #endregion

            #region Event Handlers

            private void XmlTreeSerializer_UnknownAttribute(object sender, XmlAttributeEventArgs e)
            {
                IXmlTreeSerializable serializable = e.ObjectBeingDeserialized as IXmlTreeSerializable;

                if (serializable != null)
                {
                    serializable.ReadUnknownAttribute(e.Attr);
                }
            }

            #endregion
        }
        internal interface IXmlTreeSerializable
        {
            void ReadUnknownAttribute(System.Xml.XmlAttribute attribute);
        }

Please excuse us for the inconvenience caused. We will do our best to introduce a fix accordingly.

Regards,
Dess | Tech Support Engineer, Principal
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.