Trying to build master-detail UI with controls on detail view

I’m new to UIToolkit and building simple utility app which has master list of custom objects and on selection from the list the UI will show details of object on detail view.

On the detail view I have two Toggle elements which I want to reflect and change the state of underlaying selected object’s variables. I’ve build my current setup pretty much following the logic on this Unity - Manual: Create a list view runtime UI

What would be the correct logic to handle the binding or registering callbacks on the detail UI? My current attempts of registering toggle callbacks when something is selected from list ends up messing the values also on the other objects that are not selected.

Replying to my own question for future readers, the way I ended up doing this:

  1. whenever new object is selected from main list view, I first unregister all the callbacks that are associated with toggle controls on the detail view
  2. setup the states of toggle controls as they are stored into selected object’s properties
  3. register the callbacks for toggle controls again so that user action’s are received and can be acted upon.

Don’t know if this is the correct™ way or efficient, but this seems to work.