user25033240
user25033240

Reputation: 39

How to pass data with ShowPopupAsync in .NET MAUI from calling ViewModel to Popup VieModel?

I tried to follow the Microsoft tutorial on passing data from the calling ViewModel to the Popup ViewModel on the following website: https://learn.microsoft.com/en-us/dotnet/communitytoolkit/maui/views/popup

Nonetheless, I don't understand exactly how I can pass data. My question: Does anybody know, how I may pass e.g. string or integer data? Do I need to use ApplyQueryAttributes?

I thought I could pass data like similar when using NavigateToAsync with QueryAttributes, e.g. NavigationService.NavigateToAsync($"DestinationView?userId={User.ID}"); but it does not seem that trivial.

How may I perform that?

Upvotes: 0

Views: 460

Answers (1)

Jason
Jason

Reputation: 89082

this is covered in the docs

this.popupService.ShowPopup<MyPopupViewModel>(onPresenting: viewModel => viewModel.CallSomeMethod(10));

or

this.popupService.ShowPopup<MyPopupViewModel>(onPresenting: viewModel => viewModel.SomeProperty = 10);

Upvotes: 0

Related Questions