Navigation and pass parameters. #52
-
Sorry for disturbing, but I check sample and docs and didn't find how can pass params with navigation. if it's possible, can you provide some example how to handle it. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
You're not the first one asking, so I should probably update the docs with a specific simple example :) So here it is in the mean time. Let's say you have your Inside public Task ContactSelected(Contact contact)
{
// Create navigation descriptor
var navigation = Navigation.Relative()
.Push<ContactDetailPageModel>()
.WithIntent(contact);
// Invoke Nalu's INavigationService
return _navigationService.GoToAsync(navigation);
} The method Then your So let's suppose loading contact information takes a while, and you want your page to display a loader and when the page appears you start loading information.
So you would implement public partial class ContactDetailPageModel(IContactLoadingService contactLoadingService)
: ObservableObject, IAppearingAware<Contact>
{
public async ValueTask OnAppearingAsync(Contact contact)
{
this.ContactDetails = await contactLoadingService.LoadContactDetails(contact);
}
} Refer to Navigation Events section in the documentation for more details/use cases. |
Beta Was this translation helpful? Give feedback.
-
@albyrock87 Thanks. one more question, I saw in documentation Navigation.Relative() and Navigation.Absolute() - whats difference? |
Beta Was this translation helpful? Give feedback.
You're not the first one asking, so I should probably update the docs with a specific simple example :)
So here it is in the mean time.
Let's say you have your
ContactsPageModel
and when the user presses on a contact, you want to open aContactDetailPageModel
for the tapped contact.Inside
ContactsPageModel
you should have your command (here I'm using CommunityToolkit MVVM as an example).