Closed DavidSpecter closed 2 years ago
@DavidSpecter i would recommend using my plugin or following acaliaro's guide
Both of these are based on Rg
@DavidSpecter did u get a solution for this I would rather use something that more widley used
I actually achieved this using the messaging centre
@davidbuckleyni messagingcentre also works a treat in this scenario, its what i first before i made my plugin. just remember to unsubscribe when you 'close' your popup, otherwise there will be unusual headaches, as well as a performance impact
Hi,
I resolve like that:
In popup page add a TaskCompletionSource
private TaskCompletionSource<bool> taskCompletionSource;
public Task<bool> PopupClosedTask { get { return taskCompletionSource.Task; } }
protected override void OnAppearing() { base.OnAppearing(); taskCompletionSource = new TaskCompletionSource<bool>(); }
and than set the result when button is pressed
private void ButtonClicked(object sender, EventArgs args) { taskCompletionSource.SetResult(true); Navigation.RemovePopupPageAsync(this); }
and the caller is like
Popup popup = new popup(...)
await PopupNavigation.Instance.PushAsync(popup);
if (await popup.PopupClosedTask) { //do some stuff... }
Hope this can be helpfull.
David.
@davidbuckleyni messagingcentre also works a treat in this scenario, its what i first before i made my plugin. just remember to unsubscribe when you 'close' your popup, otherwise there will be unusual headaches, as well as a performance impact
Yeah I found out about unloading the hard way wondering why my app started freezing i placed it in the close as seemed logical their.
🚀 Feature Requests
Get a return value in Xamarin Forms
Describe the feature
Simply return true or false when button in popup is pressed
Platforms affected (mark all that apply)