Reputation: 129
I have used rg.plugins.popup
in my application. I have updated the xamarin forms (version="2.5.0.121934"). Now the outer background is clicked it is not closed. I used to close the popup many ways, but not closed, I tried the below code:
this.CloseWhenBackgroundIsClicked = false;
protected override bool OnBackgroundClicked()
{
Navigation.PopPopupAsync();
return false;
}
OnBackgroundClicked
is not calling. How to fix this issue?
Upvotes: 0
Views: 7683
Reputation: 322
Maybe a little late answer. But i think someone will need it. You should override the backbutton from MainActivity.
//add this to inside the Android MainActivity
public async override void OnBackPressed()
{
if (Rg.Plugins.Popup.Popup.SendBackPressed(base.OnBackPressed))
{
await PopupNavigation.Instance.PopAsync();
}
else
{
// Do something if there are not any pages in the `PopupStack`
}
}
Upvotes: 1
Reputation: 11
At first, I put all my StackLayout in a ScrollView and I had the same problem. Then I remove the ScrollView and it works.
Upvotes: 1
Reputation: 180
I had the same problem, in my case it was about not understanding how this plugin works.
First time I used the popup I placed a StackLayout on the center of the screen with this.CloseWhenBackgroundIsClicked = true
and it worked pretty well, the problem was when I placed a GridLayout with columns 10*, 80*, 10* and rows 10*, 80*, 10*. my content was going in grid.rows(1), grid.columns(1). the other lines and columns were just borders.
If I clicked the borders it would'nt work because I was touching the grid sides and not the actually background.
The solution was change Grid for stacklayout and center it.
Upvotes: 0
Reputation: 1074
I don't understand if you know that the correct code is: this.CloseWhenBackgroundIsClicked = true;
(not false), but if this is not working you could try a workaround until this problem is solved.
Basically, add a Grid as the root of your PopupPage and add a Colorless BoxView with a TapGestureRecognizer as a child of the Grid, then just add the actual content as another child of the Grid and set the Tapped of the TapGestureRecognizer to the "BackgroundClicked" code.
Hope it helps!
Upvotes: 5