Page 1 of 1

OnPropertyChanged

Posted: 09 Nov 2019, 04:37
by MattNiznak
I'm trying to not have to use the NoesisAPP dll for my project, and I've gotten to the point where I'm trying to bind a property (for a textbox) to a NsString variable. I can set the variable directly with NsStringVar = myconstcharptrvar, but whenever I use the textbox to reflect back information, the mpBegin == "" and mpEnd = "myString"... I'm wondering if because i'm not using noesisAPP.dll and as such am defining my own iNotifyPropertyBase class (which doesn't have a "OnPropertyChanged(const char* var)" function, I might be missing something?

Re: OnPropertyChanged

Posted: 13 Nov 2019, 09:41
by sfernandez
Hi, sorry but I don't understand exactly what you are trying to explain, could you please elaborate a bit more, maybe adding your class definition.

Re: OnPropertyChanged

Posted: 13 Nov 2019, 11:36
by jsantos
Just an important clarification, NoesisApp is a layer we created for our demos and to showcase integration scenarios. It is not needed at all for any fundamental functionality of Noesis. In fact we do not recommend using NoesisApp in your own applications or games.

Re: OnPropertyChanged

Posted: 14 Nov 2019, 04:56
by MattNiznak
So I figured it out... it was me implementing NotifyPropertyChangedBase... I had:

class NotifyPropertyChangedBase : public Noesis::INotifyPropertyChanged, public Noesis::BaseComponent

with

NS_IMPLEMENT_INLINE_REFLECTION(WpfApp::NotifyPropertyChangedBase, INotifyPropertyChanged)

and while this ran, the reflection pushed my data back 8 bytes.

It should have been:

class NotifyPropertyChangedBase : public Noesis::BaseComponent, public Noesis::INotifyPropertyChanged

with

NS_IMPLEMENT_INLINE_REFLECTION(WpfApp::NotifyPropertyChangedBase, Noesis::BaseComponent)


I still had one issue let, however: if I call a setter from inside code, it will change the data value in my Model, but it won't reflect back onto the screen... I assume that there is something to do with "OnPropertyChanged" that your NoesisAPP adds? How do I get it to reflect backwards onto the screen from application? Do I have to track which objects in the xaml operate on the property and tell them to setText?

Re: OnPropertyChanged

Posted: 14 Nov 2019, 11:19
by sfernandez
That makes sense, you should take a look at the interfaces section in our C++ tutorial: https://www.noesisengine.com/docs/Gui.C ... interfaces
I think you are missing now the NsImpl<INotifyPropertyChanged>(); inside the reflection implementation block. That is required to expose the interface in the reflection, so DynamicCast can work correctly and then bindings can hook to property changes in that object.