-
Notifications
You must be signed in to change notification settings - Fork 17
Open
Description
Hi, when working with ViewModelInstances located in a List property, property callbacks (like OnTriggered) are not being executed, even though the triggers themselves fire correctly.
Steps to Reproduce
Create a ViewModel with a list property containing child ViewModels:

Create a child ViewModel with a trigger property:

Subscribe to the trigger callback in code:
for (var index = 0; index < _buttons.Count; index++)
{
var buttonInstance = _buttons.GetInstanceAt(index);
var onClickTrigger = buttonInstance.GetTriggerProperty("onClicked");
onClickTrigger.OnTriggered += () => Debug.Log("Button clicked");
}
Expected Behaviour
The OnTriggered callback should execute when the trigger fires.
Actual Behaviour
The onClicked trigger fires correctly, but the OnTriggered callback is never executed.
Root Cause
In ViewModelInstanceListProperty.cs, the method GetOrCreateVMInstanceFromPtr does not pass RootInstance to GetOrCreateFromPointer, which prevents proper child ↔ parent binding.
Current code:
private ViewModelInstance GetOrCreateVMInstanceFromPtr(IntPtr instancePtr)
{
if (instancePtr == IntPtr.Zero)
{
return null;
}
return ViewModelInstance.GetOrCreateFromPointer(instancePtr, this.RootInstance?.RiveFile);
}
Proposed Solution
Pass this.RootInstance as the third parameter:
private ViewModelInstance GetOrCreateVMInstanceFromPtr(IntPtr instancePtr)
{
if (instancePtr == IntPtr.Zero)
{
return null;
}
return ViewModelInstance.GetOrCreateFromPointer(instancePtr, this.RootInstance?.RiveFile, this.RootInstance);
}
Cheers and keep up the good work!
Metadata
Metadata
Assignees
Labels
No labels