Maui icon indicating copy to clipboard operation
Maui copied to clipboard

Make it possible to pass parameters over to INavigation based popups

Open bijington opened this issue 8 months ago • 6 comments

Description of Change

Linked Issues

  • Fixes #2696

PR Checklist

  • [ ] Has a linked Issue, and the Issue has been approved(bug) or Championed (feature/proposal)
  • [ ] Has tests (if omitted, state reason in description)
  • [ ] Has samples (if omitted, state reason in description)
  • [ ] Rebased on top of main at time of PR
  • [ ] Changes adhere to coding standard
  • [ ] Documentation created or updated: https://github.com/MicrosoftDocs/CommunityToolkit/pulls

Additional information

bijington avatar Jun 17 '25 19:06 bijington

Thanks Shaun!

I advocate against implementing this because there are already ways for developers to pass in values to their popup via Dependency Injection, DataBinding, Messaging Services, etc.

Yes, I know this feature existed in Popup v1, but to be honest it is a bit of anti-pattern implementing a messaging service into Popup and we should have never supported it. I am not aware of any developer who is blocked without this feature.

If a developer can provide a sample app demonstrating how they are blocked without this feature, I'm happy to readdress this feature.

TheCodeTraveler avatar Jun 17 '25 19:06 TheCodeTraveler

This scenario only introduces the ability to pass data in at the point of creation/navigating so I don't think DataBinding or Messaging Services are suitable alternatives.

As for developers being blocked there are some over here: https://github.com/CommunityToolkit/Maui/discussions/2696#discussioncomment-13500610

bijington avatar Jun 17 '25 19:06 bijington

@bijington could you please explain how they will use the parameters? PopupPage is internal and I don't know how it replaces onPresenting.

I agree with @TheCodeTraveler. At least they can subscribe to Opened event and set parameters they need.

VladislavAntonyuk avatar Jun 18 '25 03:06 VladislavAntonyuk

@bijington could you please explain how they will use the parameters? PopupPage is internal and I don't know how it replaces onPresenting.

I agree with @TheCodeTraveler. At least they can subscribe to Opened event and set parameters they need.

Happy to... this doesn't introduce any new concepts it just makes the use of Popups in non-Shell based apps symmetrical with Shell based apps. The parameters would work as per our documentation https://learn.microsoft.com/en-us/dotnet/communitytoolkit/maui/views/popup-service#passing-data-to-a-popup-view-model only for the methods that accept INavigation and not only Shell.

My intention was never to replace onPresenting, I would have left that in. IQueryAttributable was a compromise but the initial implementation only supported Shell based apps

bijington avatar Jun 18 '25 05:06 bijington

Yes, but you cast popupPage to IQueryAttributable. Maybe you should do it with ViewModel or View?

VladislavAntonyuk avatar Jun 18 '25 06:06 VladislavAntonyuk

Yes, but you cast popupPage to IQueryAttributable. Maybe you should do it with ViewModel or View?

Oh I see your point. PopupPage is a wrapper for the content so it delegates down to the content view/view model. I've removed the explicit implementation of IQueryAttributable so we don't need to cast

bijington avatar Jun 18 '25 07:06 bijington