On a MAUI app, I'm trying to pass a value from one page to another through their respective ViewModels, but it's not working and for the life of me I can't figure out why.
Source VM:
[RelayCommand]
public async Task GetAdvertDetailsPageAsync(int advertId)
{
await Shell.Current.GoToAsync($"{nameof(AdvertDetails)}?AdvertId={advertId.ToString()}");
}
Destination VM:
[QueryProperty("AdvertId", "AdvertId")]
public partial class AdvertDetailsVM : ObservableObject
{
[ObservableProperty]
public string advertId;
public AdvertDetailsVM(IMyHttpClient httpClient)
{
LoadAdvertAsync(Convert.ToInt32(AdvertId));
}
Destination ContentPage:
public partial class AdvertDetails : ContentPage
{
public AdvertDetails(AdvertDetailsVM vm)
{
InitializeComponent();
BindingContext = vm;
}
}
The parameter advertId on the GetAdvertDetailsPageAsync on the source page has a value, the destination page gets called, and the ViewModel gets injected just fine, but the AdvertId property on the destination comes up empty and I can't figure out why. For the record, I'm following this tutorial
Thanks in advance