How can I bind a property in list field ?

public class Test : EditorWindow
{
    public ClassA classA;
    void CreateGUI()
    {
        var label = new Label();
        rootVisualElement.Add(label);

        //If I want to bind the property of classA.classBList[1].b, what is it bindingPath?
        label.bindingPath = ?;

        label.Bind(new SerializedObject(classA));
    }

}


public class ClassA : ScriptableObject
{
    public List<ClassB> classBList = new List<ClassB>();
}

[Serializable]
public class ClassB
{
    public string b;
}

Like this, If I want to bind the property of classA.classBList[1].b, what is it bindingPath?

Hi,
bindingPath, to my knowledge, doesn’t support indices/lists. I guess your best bet is to keep a “current” classB in your ClassA definition and set binding path to that field…

public ClassA : ScriptableObject
{
    List<ClassB> classBList = new List<ClassB>();
    public ClassB currentClassB;
}

void CreateGUI()
{
    var label = new Label();
    rootVisualElement.Add(label);
    label.bindingPath = "currentClassB.b";  // currentClassB would refer to the entry at [1] in your example
    label.Bind(new SerializedObject(classA));
}

Not looking good but that would be the easiest way for now.

I had this doubt because of want to show something when multied select in list view, so I need a lists to save what the item selected. Although that is not the best way, but I like it, thanks.