C#C
C#3y ago
Knightfox

❔ .NET MAUI MVVM Navigation and pass Object to new page, Throw Exception: Missing method

Program crash after this code
[RelayCommand]
        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;

    }
}



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);
Was this page helpful?