Issue driving component bindings with UObject / AActor
Posted: 05 Nov 2025, 23:00
Hey all,
I've written a custom component that I'd like to reuse which I reference in my main xaml file like this:
Where MyObjects is an array of type that inherits from AActor.
Inside of the component xaml file I have something like this:
My intent here is to provide one of the entries in MyObjects as a reference to the DataRef of my component so that I can bind elements like visibility to properties of that object.
It works perfectly fine if I am explicitly setting the DataContext inside of the component to the Ancestor array entry directly like this:
Obviously this isn't scalable so I am wondering why I can't just pass it in like I was above.
Thinking maybe there is something wrong on the C++ side so I tried something like this:
But I guess this type of RegisterProperty only works with primitive data types? Maybe I am also misunderstanding...
Appreciate any help that can be given here!
I've written a custom component that I'd like to reuse which I reference in my main xaml file like this:
Code: Select all
<local:MyComponent x:Name="Component1" DataRef="{Binding MyObjects[2]}"/>Inside of the component xaml file I have something like this:
Code: Select all
<Grid x:Name="MyComponentGrid"
Width="700" Height="700"
DataContext="{Binding DataRef, RelativeSource={RelativeSource AncestorType=UserControl}}">
<Image x:Name="MyComponentImage"
Source="Images/sourceimg.png"
Visibility="{Binding bShouldShowImg,
Converter={StaticResource BoolToVisibilityConverter}}"/>
It works perfectly fine if I am explicitly setting the DataContext inside of the component to the Ancestor array entry directly like this:
Code: Select all
<Grid DataContext="{Binding DataContext.MyObjects[2], RelativeSource={RelativeSource AncestorType=UserControl, AncestorLevel=2}}">Obviously this isn't scalable so I am wondering why I can't just pass it in like I was above.
Thinking maybe there is something wrong on the C++ side so I tried something like this:
Code: Select all
NS_BEGIN_COLD_REGION
NS_IMPLEMENT_REFLECTION(NameSpace::MyComponent, "NameSpace.MyComponent")
{
auto* dd = NsMeta<DependencyData>(TypeOf<SelfClass>());
dd->RegisterProperty<AActor*>(
SeatDataProperty, "DataRef",
Noesis::PropertyMetadata::Create<AActor*>(nullptr));
}
NS_END_COLD_REGIONAppreciate any help that can be given here!