Search code examples
c#xamarinmvvmcrossuipopovercontroller

how to call MvxDialogViewController as a popover


I am trying to display MxxDialogViewController from a popover and am getting an exception

18.35 Request is null - assuming this is a TabBar type situation where ViewDidLoad is called during construction... patching the request now - but watch out for problems with virtual calls during construction

while calling base.ViewDidLoad()

here is what I did to demonstrate the problem as a small sample:

I took N-23 example and added to the first section a new element with the Tapped command

new StringElement("test Popover", Tapped),

here is Tapped(), as a test I am trying to display the same FirstView in a popover.

    private void Tapped()
    {
        var dvc = new FirstView();
        var nc = new UINavigationController(dvc);
        _ardlViewPopover = new UIPopoverController(nc);

        _ardlViewPopover.PresentFromRect(this.View.Frame, this.View, UIPopoverArrowDirection.Any, true);
    }

Should MvxDialogViewController work inside of a popover controller?

Thank you

Mark


Solution

  • The error message is Request is null

    Try setting the Request property for the FirstView - e.g. if there are no parameters then use:

    var dvc = new FirstView();
    dvc.Request = MvxViewModelRequest<FirstViewModel>.GetDefaultRequest();