Page 1 of 1

How to register attached property of complex type?

Posted: 23 Jul 2021, 23:33
by jsteedVR
Hi, I'm trying to register a property of type Noesis::TreeViewItem* in my TreeView-derived custom control, but I can't for the life of me figure out why this doesn't work:
data->RegisterProperty<TreeViewItem*>(SelectedItemsStartProperty, "SelectedItemsStart", FrameworkPropertyMetadata::Create<TreeViewItem*>(nullptr));
It builds, but I get the runtime error left of '.GetHashCode' must have class/struct/union.
The examples in the documentation are only for floats, and in general, it'd be nice to see better examples beyond the most basic use case.

I'm running Noesis 2.2 C++ SDK, if that's any help.

Re: How to register attached property of complex type?

Posted: 24 Jul 2021, 01:33
by sfernandez
For ref counted objects (inheriting from BaseComponent) we are storing the dependency property using a Ptr and the definition should look like this:
data->RegisterProperty<Ptr<TreeViewItem>>(SelectedItemsStartProperty, "SelectedItemsStart",
    FrameworkPropertyMetadata::Create<Ptr<TreeViewItem>>(nullptr));

Re: How to register attached property of complex type?

Posted: 24 Jul 2021, 03:01
by jsteedVR
Thank you so much!
I swear I tried it before but I must've gotten something wrong. :)