i have a binding on a text field as follows:
<Label Grid.Row="1" Grid.Column="1" FontFamily="FontCamptonMedium" FontSize="12" Text="{Binding CurrentBooking.FullName}" TextColor="Black" />
in the code-behind of this page, we use dependency injection to bind to the corresponding view model, like so:
public AppointmentPendingResponse(BookingViewModel viewModel): base(viewModel)
{
InitializeComponent();
BindingContext = viewModel;
}
this view model that we are binding to inherits from another baseviewmodel, like this…
public partial class BookingViewModel : BaseViewModel
…which in turn, is declared like this:
public abstract partial class BaseViewModel : ObservableObject, IQueryAttributable, INotifyPropertyChanged
in the baseviewmodel we implement the following to make use of inotifypropertychanged:
public event PropertyChangedEventHandler PropertyChanged;
protected bool SetProperty<T>(ref T backingStore, T value,
[CallerMemberName] string propertyName = "",
Action onChanged = null)
{
if (EqualityComparer<T>.Default.Equals(backingStore, value))
return false;
backingStore = value;
onChanged?.Invoke();
OnPropertyChanged(propertyName);
return true;
}
protected void OnPropertyChanged([CallerMemberName] string propertyName = "")
{
var changed = PropertyChanged;
if (changed == null)
return;
changed.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
inside the bookingviewmodel, we then populate the CurrentBooking property like this:
CurrentBooking = (BookingModel)selected;
the resulting json looks like this:
{"FullName":"LAWMAN","IdentityNo":"123","Relation":"SELF"}
the fact that i am able to get json data means CurrentBooking should not be null. so why is my label text not being populated? im not sure what im missing here.