CommunityToolKit PopupService Public GetPopup Method #1648
Closed
bobbydharrell
started this conversation in
New Feature Discussions
Replies: 1 comment 3 replies
-
If Popup is registered as transient you will get a new instance of Popup each time. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have forked this so that I could add the code in question. We use a custom PopupService in our apps that handles any popups. The need to close a popup from the ViewModel arose but we discovered there was no easy way to do this as the ViewModels had no context of the Views. I found that the Toolkit.PopupService had an internal GetPopup that would look up the Popup by ViewModel, so I added another public method that takes in ViewModel and then looks up the popup from there.
The intended use case would be from within a custom popup Service
ViewModel Calls PopupDialogService.ClosePopup()
PopupDialogService.ClosePopup()
{
Popup popup = PopupService.GetPopup();
popup.Close();
}
I also see a need for a PopupService.OpenPopups List, but that may be another ticket, if that can be handled here then, perfect.
For clarity, the PopupService.OpenPoups would return list of all open Popups, and would be used for scenarios where one would need to close all, or see if a certain popup is currently open
See my fork for the changes
main...bobbydharrell:Maui:main
Thanks
Beta Was this translation helpful? Give feedback.
All reactions