In C#, I often created property getters that returned the result of a function call. This meant that I was required to trigger property change notifications manually using OnPropertyChanged. This process is well documented for C# and VB, but I can’t seem to find a C++/CX equivalent. Does such a thing exist, or do I have to find a new programming pattern?
Here’s a basic example to show my issue:
public:
property int FooSquared {
int get() { return _calculateFooSquared(); }
}
private:
int _foo;
int _calculateFooSquared() {
return _foo * _foo;
}
void _setNewFoo(int newFoo) {
// When _foo gets updated here, anyone bound to FooSquared
// needs to be updated. How do I trigger an update?
_foo = newFoo;
}
The same way you do in c#, implement INotifyPropertyChanged. MSDN article with samples