private void Refresh()
        {
            m_ScrollView.Clear();

            m_BindingsTestObject = ScriptableObject.CreateInstance <BindingsTestObject>();
            var serializedObject = new SerializedObject(m_BindingsTestObject);

            if (serializedObject == null)
            {
                return;
            }

            // Loop through properties and create one field for each top level property.
            SerializedProperty property = serializedObject.GetIterator();

            property.NextVisible(true); // Expand the first child.
            do
            {
                // Create IMGUIContainer for the IMGUI PropertyField.
                var copiedProperty    = property.Copy();
                var imDefaultProperty = new IMGUIContainer(() => { DoDrawDefaultIMGUIProperty(serializedObject, copiedProperty); });
                imDefaultProperty.name = property.propertyPath;

                // Create the UIElements PropertyField.
                var uieDefaultProperty = new PropertyField(property);

                var row = NewRow(imDefaultProperty, uieDefaultProperty);
                m_ScrollView.Add(row);
            }while (property.NextVisible(false));

            // Bind the entire ScrollView. This will actually generate the VisualElement fields from
            // the SerializedProperty types.
            m_ScrollView.Bind(serializedObject);

            // IMGUIContainers currently do not resize properly when the IMGUI elements inside
            // change size. This hack ensures that upon Foldout expansion/contraction the
            // corresponding IMGUIContainer is forced to resize.
            foreach (var foldout in m_ScrollView.Query <Foldout>().ToList())
            {
                foldout.RegisterValueChangedCallback((e) =>
                {
                    var fd = (e.target as Foldout);
                    if (fd == null)
                    {
                        return;
                    }

                    var path      = fd.bindingPath;
                    var container = m_ScrollView.Q <IMGUIContainer>(name: path);
                    RecomputeSize(container);
                });
            }
        }
        public void OnEnable()
        {
            // Each editor window contains a root VisualElement object
            VisualElement root = rootVisualElement;

            var asset = AssetDatabase.LoadAssetAtPath <VisualTreeAsset>("Assets/Examples/Editor/Bindings/ListViewBinding.uxml");

            root.styleSheets.Add(AssetDatabase.LoadAssetAtPath <StyleSheet>("Assets/Examples/Editor/Bindings/ListViewBinding.uss"));

            asset.CloneTree(root);


            m_BindingsTestObject = ScriptableObject.CreateInstance <BindingsTestObject>();
            ResetValues();

            var status = root.Q <Label>("status");

            var serializedObject = new SerializedObject(m_BindingsTestObject);

            if (serializedObject == null)
            {
                status.text = "Unable to create SerializedObject!";
                return;
            }


            root.Bind(serializedObject);

            //We verify that the list data was correctly bound
            root.Query <ListView>().ForEach((lv) =>
            {
                if (lv.itemsSource == null)
                {
                    status.text = "Failed to Bind Array to ListView";
                }
                else
                {
                    status.text = "ListView bound successfully";
                }
            });

            BindButton("reset-button", ResetValues);
            BindButton("dump-button", LogValues);
            BindButton("random-button", RandomizeValues);
        }