Converter to get TYPE and compare with x:Type
Hi,
I've successfully made this converter in WPF: ObjectToTypeConverter
Which basically returns this: value.GetType()
Which allows me to do this:
<DataTrigger Binding="{Binding, Converter={StaticResource ObjectToType}}" Value="{x:Type vm:SomeViewModel}">
However I am having trouble making this work in Noesis. I've tried returning value->GetClassType(), and a few other ideas, but none seem to work. How can I do the equivalent?
EDIT: I have got round this by making an ObjectIsTypeConverter, where I use the converter parameter to pass the type I want to check against, and that is working fine - however I would still like to get this working.
Many thanks,
Mark.
I've successfully made this converter in WPF: ObjectToTypeConverter
Which basically returns this: value.GetType()
Which allows me to do this:
<DataTrigger Binding="{Binding, Converter={StaticResource ObjectToType}}" Value="{x:Type vm:SomeViewModel}">
However I am having trouble making this work in Noesis. I've tried returning value->GetClassType(), and a few other ideas, but none seem to work. How can I do the equivalent?
EDIT: I have got round this by making an ObjectIsTypeConverter, where I use the converter parameter to pass the type I want to check against, and that is working fine - however I would still like to get this working.
Many thanks,
Mark.
-
sfernandez
Site Admin
- Posts: 2995
- Joined:
Re: Converter to get TYPE and compare with x:Type
Hi, the converter should box the Type returned by the value:
Code: Select all
struct ObjectToTypeConverter: BaseValueConverter
{
bool TryConvert(BaseComponent* value, const Type*, BaseComponent*, Ptr<BaseComponent>& result) override
{
if (value != nullptr)
{
const Type* type = value->GetClassType();
result = Boxing::Box(type);
return true;
}
return false;
}
NS_IMPLEMENT_INLINE_REFLECTION_(ObjectToTypeConverter, BaseValueConverter, "SomeNamespace.ObjectToTypeConverter")
};
Re: Converter to get TYPE and compare with x:Type
I meant to say that I did try boxing it first. I will try again though, I may have missed something the first time round.
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 16 guests