Knightfox
❔ .NET MAUI MVVM Navigation and pass Object to new page, Throw Exception: Missing method
Program crash after this code
This is the ViewModel on the next page
This is the page 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}
});
}
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;
}
}
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