jsteedVR
Topic Author
Posts: 8
Joined: 26 Feb 2020, 01:44

How to register attached property of complex type?

23 Jul 2021, 23:33

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.
 
User avatar
sfernandez
Site Admin
Posts: 2983
Joined: 22 Dec 2011, 19:20

Re: How to register attached property of complex type?

24 Jul 2021, 01:33

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));
 
jsteedVR
Topic Author
Posts: 8
Joined: 26 Feb 2020, 01:44

Re: How to register attached property of complex type?

24 Jul 2021, 03:01

Thank you so much!
I swear I tried it before but I must've gotten something wrong. :)

Who is online

Users browsing this forum: Google [Bot] and 74 guests