Question

Hello i need to prevent my popover from dismissing when clicking outside the box.

I found some answers but all in objective C and i cant understand it very well.

Stop UIPopover from dismissing automatically

Anyone knows how to do that in xamarin?

Was it helpful?

Solution

UIKit's [UIPopoverControllerDelegate popoverControllerShouldDismissPopover:] translates to UIPopoverControllerDelegate.ShouldDismiss in MonoTouch.

popover.Delegate = new MyPopoverDelegate();

...

class MyPopoverDelegate : UIPopoverControllerDelegate
{
    public override bool ShouldDismiss (UIPopoverController popoverController)
    {
        return false;
    }
}

I'm not completely positive, but I believe you can also just have your main class implement the IUIPopoverControllerDelegate interface and add ShouldDismiss directly to it:

popover.Delegate = this;

...

public override bool ShouldDismiss (UIPopoverController popoverController)
{
    return false;
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top