How binding a element of TArray?
I want to binding to TArray[0], so is there a way to get TArray[0], I find a class NoesisArrayWrapper, but in Private directory. may be I need a fucntion such as NoesisCreateTArrayForComponent?
Code: Select all
<Button Content="{Binding SpellList, Converter={StaticResource SpellIndexConverter}, ConverterParameter=0}" Width="236.5" Height="100" Canvas.Left="345" Canvas.Top="529.5">
</Button>
Code: Select all
bool SpellIndexConverter::TryConvert(BaseComponent* value, const Type* targetType, BaseComponent* parameter, Ptr<BaseComponent>& result)
{
int Idx = Boxing::Unbox<int>(parameter);
//UObject* Array = NoesisCreateUObjectForComponent(value);
/*NoesisArrayWrapper* Array = NsDynamicCast<NoesisArrayWrapper>(value);
if (Array)
{
return Array->NativeGet(Idx);
}*/
return false;
}
Re: How binding a element of TArray?
Hi,
You shouldn't need to access the NoesisArrayWrapper class. It implements the IList interface. You should be able to do something like this:
You shouldn't need to access the NoesisArrayWrapper class. It implements the IList interface. You should be able to do something like this:
Code: Select all
bool SpellIndexConverter::TryConvert(BaseComponent* value, const Type* targetType, BaseComponent* parameter, Ptr<BaseComponent>& result)
{
int Idx = Boxing::Unbox<int>(parameter);
IList* List = NsDynamicCast<IList>(value);
if (List && Idx >= 0 && Idx < (int)List->Count() )
{
result.Reset(List->Get(Idx));
return true;
}
return false;
}
Re: How binding a element of TArray?
seems can not directly pass int 0 to ConverterParameter, the result of unbox is not a valid value.
And, how to binding the elememnt's member?
<Button Name="{Binding SpellList[0].DisplayName}"/>
unbox it to IList, may be hard to convert to UStruct?
And, how to binding the elememnt's member?
<Button Name="{Binding SpellList[0].DisplayName}"/>
unbox it to IList, may be hard to convert to UStruct?
Re: How binding a element of TArray?
Hi,
You can actually make that 0 to be parsed as an integer, in which case you would get a boxed integer, and there could be ways to get the UStruct from the IList.
But before we get into that, is <Button Content="{Binding SpellList[0].DisplayName}"/> what you're trying to do? Accessing element 0? Because that syntax you wrote should work, and you shouldn't have to write your own converter, and the Binding should take care of everything.
You can actually make that 0 to be parsed as an integer, in which case you would get a boxed integer, and there could be ways to get the UStruct from the IList.
But before we get into that, is <Button Content="{Binding SpellList[0].DisplayName}"/> what you're trying to do? Accessing element 0? Because that syntax you wrote should work, and you shouldn't have to write your own converter, and the Binding should take care of everything.
Re: How binding a element of TArray?
that's what I need. So powerfulHi,
You can actually make that 0 to be parsed as an integer, in which case you would get a boxed integer, and there could be ways to get the UStruct from the IList.
But before we get into that, is <Button Content="{Binding SpellList[0].DisplayName}"/> what you're trying to do? Accessing element 0? Because that syntax you wrote should work, and you shouldn't have to write your own converter, and the Binding should take care of everything.
Re: How binding a element of TArray?
Thanks! Marking this as solved.
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot], Semrush [Bot] and 74 guests