- Susanna.Rowland
- Posts: 11
- Joined:
Attached property class with Noesis::Type property
Hi,
I am attempting to create an attached property class, with a registered property of type Noesis::Type, the idea being to be able to add the property to any node, and use the Type Extension to pass a type to my property. The property value would then be used to locate the instance of that type. I have implemented this class in C# for blend and it works, but I am having difficulty implementing it in C++.
This is how it is defined in the xaml:
And this is where I am registering the property in code:
The problem I am having is that I get multiple build errors as Noesis::Type has no default constructor and it is also attempting to use the deleted copy constructor.
I have also tried using the NsProp macro to register the property, as this has worked in a behavior class, but while that builds, I get the following error at runtime
Is there a way to register my property that will work? Or is there an alternative type I should be using for this?
Thank you
I am attempting to create an attached property class, with a registered property of type Noesis::Type, the idea being to be able to add the property to any node, and use the Type Extension to pass a type to my property. The property value would then be used to locate the instance of that type. I have implemented this class in C# for blend and it works, but I am having difficulty implementing it in C++.
This is how it is defined in the xaml:
Code: Select all
<my_node common:MyProperty.MyType="{x:Type class:MyClass}"/>
Code: Select all
NS_IMPLEMENT_REFLECTION(MyPropertyClass, "common.MyProperty")
{
Noesis::DependencyData* data = NsMeta<Noesis::DependencyData>(Noesis::TypeOf<SelfClass>());
data->RegisterProperty<Noesis::Type>(MyTypeProperty, "MyType", Noesis::PropertyMetadata::Create(Noesis::Type(Noesis::Symbol::Null())));
}
So I am guessing attached properties have to use RegisterProperty.Can't get or set property 'common.MyProperty.MyType' in a 'my_node' instance.
Is there a way to register my property that will work? Or is there an alternative type I should be using for this?
Thank you
-
sfernandez
Site Admin
- Posts: 2983
- Joined:
Re: Attached property class with Noesis::Type property
Hi, try with a pointer like we did with FrameworkElement.DefaultStyleKey property:
Code: Select all
data->RegisterProperty<const Type*>(DefaultStyleKeyProperty, "DefaultStyleKey",
FrameworkPropertyMetadata::Create<const Type*>(nullptr));
- Susanna.Rowland
- Posts: 11
- Joined:
Re: Attached property class with Noesis::Type property
That is perfect, thank you! Of all the variations I tried I somehow missed that one
Who is online
Users browsing this forum: Google [Bot] and 59 guests