Knightfox
Knightfox
CC#
Created by Knightfox on 5/18/2023 in #help
❔ .NET MAUI MVVM Navigation and pass Object to new page, Throw Exception: Missing method
Program crash after this code
async Task GoApartmentDetail(Apartment apartment)
{
if (apartment is null)
{
return;
}

await Shell.Current.GoToAsync($"{nameof(ApartmentDetailPage)}", true,
new Dictionary<string, object>
{
{"Apartment", apartment}
});
}
async Task GoApartmentDetail(Apartment apartment)
{
if (apartment is null)
{
return;
}

await Shell.Current.GoToAsync($"{nameof(ApartmentDetailPage)}", true,
new Dictionary<string, object>
{
{"Apartment", apartment}
});
}
This is the ViewModel on the next page
namespace BaviHouse.ViewModel
{
[QueryProperty("Apartment","Apartment")]
public partial class ApartmentDetailViewModel : ObservableObject
{
public ApartmentDetailViewModel()
{
}

[ObservableProperty]
Apartment apartment;

}
}
namespace BaviHouse.ViewModel
{
[QueryProperty("Apartment","Apartment")]
public partial class ApartmentDetailViewModel : ObservableObject
{
public ApartmentDetailViewModel()
{
}

[ObservableProperty]
Apartment apartment;

}
}
This is the page code
public partial class ApartmentDetailPage : ContentPage
{


public ApartmentDetailPage(ApartmentDetailViewModel vm)
{
InitializeComponent();
BindingContext = vm;
}

protected override void OnNavigatedTo(NavigatedToEventArgs args)
{
base.OnNavigatedTo(args);
public partial class ApartmentDetailPage : ContentPage
{


public ApartmentDetailPage(ApartmentDetailViewModel vm)
{
InitializeComponent();
BindingContext = vm;
}

protected override void OnNavigatedTo(NavigatedToEventArgs args)
{
base.OnNavigatedTo(args);
6 replies