Page 2 of 2

Re: [C++] Visual update on property changed

Posted: 24 Feb 2017, 11:23
by Ziriax
Thanks. And Item inherits from BaseComponent?

Re: [C++] Visual update on property changed

Posted: 24 Feb 2017, 11:44
by Ziriax
Just one more question, you are using 1.3 RC1?

Re: [C++] Visual update on property changed

Posted: 25 Feb 2017, 01:57
by sfernandez
Hi,

In the code you attached there are things I don't understand.

First you have a CheckItem inheriting from Item class but you're saying in reflection macros that it inherits from BaseComponent. Are you doing this because Item class doesn't include reflection macros? Is Item class inheriting from BaseComponent?

Then you have an Item_model inheriting from CheckItem class, and again you are saying in reflection macros that it inherits from BaseComponent, this doesn't seem right. You are also exposing the IsChecked property again, there is no need to do that unless getter/setters are different and you want to hide parent class property.

I think your classes should look something like this:
class Item: public BaseComponent {
 ...
 NS_IMPLEMENT_INLINE_REFLECTION(Item, BaseComponent) { ... }
};

class CheckItem: public Item, public INotifyPropertyChanged {
  ...
  NS_IMPLEMENT_INLINE_REFLECTION(CheckItem, Item) {
    NsMeta<TypeId>("CheckItem");
    NsImpl<INotifyPropertyChanged>();
    NsProp("IsChecked", &CheckItem::GetIsChecked, &CheckItem::SetIsChecked);
  }
};

class Item_model : public CheckItem {
  ...
  NS_IMPLEMENT_INLINE_REFLECTION(Item_model, CheckItem) {
    NsMeta<TypeId>("ListItem");
  }
};
Could you please attach the xaml where you are binding to the IsChecked property?

Thanks.