How pass parameter to XAML

Hi, I am trying to pass a paramters to the view RoomBookingPage?
In the function from Nativagiont
private void NavigateToNextPage(object selectedItem)
{
// Do something WITH the item selected.
//Go to selected house, show basic information
Application.Current.MainPage = new NavigationPage(new HouseDetail((Models.NavigationModel)selectedItem));
}
Then, in RoomBookingPage.xaml.cs, in the constructor I can get my NavigatonModel. With the XAML file I modified the ContentPage.BindingContext to obtain the information in my ViewModel:
selectedItem
But in my ViewModel, is an empty object.
public RooomBookingViewModel(Models.NavigationModel HouseSelected)
Which id the correct way to pass an object between views?
Thanks

1 Reply 1 reply marked as answer

YP Yuvaraj Palanisamy Syncfusion Team June 14, 2021 03:40 PM UTC

Hi Mike,

Greetings from Syncfusion.

We have analyzed your query and provided sample, we can’t access your db due to permission denied. Also, we have achieved your requirement “To pass parameter (selected item) into the view” with the help of following code example and you can the selected item values on the HouseDetailViewModel.cs.
 
 
CodeSnipppet: [HouseDetail.xaml] 
public HouseDetail(object HouseSelected) 
{ 
    this.InitializeComponent(); 
    this.BindingContext = new HouseDetailViewModel(HouseSelected as Models.NavigationModel);  
} 
 
Please let us know if you have any concern. 
 
Regards, 
Yuvaraj. 


Marked as answer
Loader.
Up arrow icon