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

PropertyMetadata - Property Changed Callback

25 Aug 2021, 00:19

Hi,

I have a DependencyProperty in my custom control that I am trying to register.
static const DependencyProperty *SelectedItemsProperty;
NS_IMPLEMENT_INLINE_REFLECTION(MultiSelectTreeView, TreeView)
		{
			NsMeta<TypeId>("Vital.MultiSelectTreeView");

			DependencyData *data = NsMeta<DependencyData>(TypeOf<SelfClass>());

			data->RegisterProperty<Ptr<ObservableCollection<BaseComponent>>>(SelectedItemsProperty, "SelectedItems",
				PropertyMetadata::Create(&OnSelectedItemsChanged));
		}
I want to supply the PropertyMetadata with this callback for when the property changes:
void OnSelectedItemsChanged(BaseComponent *_sender, const DependencyPropertyChangedEventArgs &e);
But when I compile, Noesis throws this error:
NoesisSDK_2.2.0\Include\NsCore/TypeOfBase.inl(29,49): error C2825: 'T': must be a class or namespace when followed by '::'
NoesisSDK_2.2.0\Include\NsGui/PropertyMetadata.inl(18): message : see reference to class template instantiation 'Noesis::ValueStorageManagerImpl<T>' being compiled
I've tried calling a few different overloads of PropertyMetadata::Create, but cannot get it to work.
The property changed callback is the only important thing I need the metadata to have. Do I need to supply a ValueStorageManager?

Can someone share some examples of how this should look?
I'm using the Noesis 2.2 C++ SDK.

Thanks in advance :)
 
User avatar
sfernandez
Site Admin
Posts: 2984
Joined: 22 Dec 2011, 19:20

Re: PropertyMetadata - Property Changed Callback

25 Aug 2021, 11:42

Hi, the correct signature for the PropertyChangedCallback is:
void PropertyChangedCallback(DependencyObject* d, const DependencyPropertyChangedEventArgs& e);
Please let us know if you find any more problems.
 
jsteedVR
Topic Author
Posts: 8
Joined: 26 Feb 2020, 01:44

Re: PropertyMetadata - Property Changed Callback

25 Aug 2021, 19:13

Hi, the correct signature for the PropertyChangedCallback is:
void PropertyChangedCallback(DependencyObject* d, const DependencyPropertyChangedEventArgs& e);
Please let us know if you find any more problems.
I still get the same error(s) using that signature.
 
User avatar
sfernandez
Site Admin
Posts: 2984
Joined: 22 Dec 2011, 19:20

Re: PropertyMetadata - Property Changed Callback

27 Aug 2021, 10:12

Sorry for the late answer. The following code compiles fine with NoesisGUI 2.2 version:
class MultiSelectTreeView : public TreeView
{
public:
  static const DependencyProperty *SelectedItemsProperty;
private:
  static void OnSelectedItemsChanged(DependencyObject* d, const DependencyPropertyChangedEventArgs& e)
  {
  }
  
  NS_IMPLEMENT_INLINE_REFLECTION(MultiSelectTreeView, TreeView)
  {
    NsMeta<TypeId>("Vital.MultiSelectTreeView");

    DependencyData *data = NsMeta<DependencyData>(TypeOf<SelfClass>());
    data->RegisterProperty<Ptr<ObservableCollection<BaseComponent>>>(SelectedItemsProperty, "SelectedItems",
      PropertyMetadata::Create(PropertyChangedCallback(OnSelectedItemsChanged)));
  }
};
 
jsteedVR
Topic Author
Posts: 8
Joined: 26 Feb 2020, 01:44

Re: PropertyMetadata - Property Changed Callback

27 Aug 2021, 22:32

Ah, that works.
The part that was not obvious to me was that OnSelectedItemsChanged needed to be wrapped in a PropertyChangedCallback inside PropertyMetadata::Create parameter.

As always, thanks a ton for the help!
 
User avatar
jsantos
Site Admin
Posts: 3906
Joined: 20 Jan 2012, 17:18
Contact:

Re: PropertyMetadata - Property Changed Callback

27 Aug 2021, 22:59

Thanks for the feedback. Also note that 2.2 is incredibly old, we recommend upgrading to 3.1
 
jsteedVR
Topic Author
Posts: 8
Joined: 26 Feb 2020, 01:44

Re: PropertyMetadata - Property Changed Callback

27 Aug 2021, 23:16

We are currently in the discovery phase of what work it will take to upgrade our codebase to 3.1 in the next month or two, but we are very excited for it.
Thanks again for all that you guys do!

Who is online

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