Binding property from extended ViewModel

Hi, I have this scenario:

  • ViewModelBase

    • Title Property
  • NotificationsViewModel : ViewModelBase

  • NotificationsPage

    • BindingContext = NotificationsViewModel
    • Title = {Binding Title}

But my title property doesn't update from ViewModelBase... It is possible to do this? What I do wrong?

Best Answer

  • RockbeatRockbeat ✭✭
    Accepted Answer

    I found what I did wrong,

    I used a wrong Constructor of ViewModelBase, instead, I put the Property initialize on OnNavigatingTo function. Now the title updates correctly.

Answers

  • RockbeatRockbeat Member ✭✭

    I usually declare the properties like:

        private bool _title;
        public bool Title
        {
            get { return _title; }
            set { SetProperty(ref _title, value); }
        }
    
  • RockbeatRockbeat Member ✭✭
    Accepted Answer

    I found what I did wrong,

    I used a wrong Constructor of ViewModelBase, instead, I put the Property initialize on OnNavigatingTo function. Now the title updates correctly.

Sign In or Register to comment.