Bug 28387 - ModalWrapper breaks things
Summary: ModalWrapper breaks things
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 1.4.0
Hardware: PC Mac OS
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2015-03-24 18:01 UTC by Adam Kemp
Modified: 2015-06-11 19:26 UTC (History)
5 users (show)

Tags: ios customrenderer navigation NGF
Is this bug a regression?: ---
Last known good build:

Test case (4.12 MB, application/zip)
2015-03-24 18:01 UTC, Adam Kemp

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Adam Kemp 2015-03-24 18:01:11 UTC
Created attachment 10481 [details]
Test case

This is a redux of this other bug:

Now in addition to NavigationPage wrapping view controllers modal pages are also wrapped in a parent view controller, and this breaks simple use cases for custom page renderers. In this case what I'm trying to do is set a ModalPresentationStyle of the custom renderer, which I should be able to do in the constructor:

        public ModalPageRenderer()
            ModalPresentationStyle = UIModalPresentationStyle.FormSheet;

That doesn't work because the actual property used to decide how to display the page is in the ModalWrapper class, which becomes the parent of this view controller.

To reproduce this run the attached project and click the button. What you should see is a form sheet with a button to dismiss. Instead you see a full screen page with a button to dismiss.

To work around the bug you can uncomment this code in the custom renderer:

        public override void WillMoveToParentViewController(UIViewController parent)

            if (parent != null)
                parent.ModalPresentationStyle = ModalPresentationStyle;

This should NOT be needed. If you are going to wrap our page renderers automatically then you should be forwarding ALL properties that affect the display and behavior of the view controller to the child. That includes things like rotation behavior, status bar behavior, presentation style, everything in NavigationItem, etc.

I have seen several people get confused by this on the Xamarin forums because it's not expected behavior, and understanding why it doesn't work requires understanding the private implementation of Xamarin.Forms. Worse, it has changed behavior (so this is a regression).

Please keep this kind of stuff in mind when implementing Xamarin.Forms. Wrappers need to be transparent so that they don't interfere with the wrapped objects.
Comment 1 Adam Kemp 2015-03-24 18:08:15 UTC
This is iOS-specific.
Comment 2 Jason Smith [MSFT] 2015-05-18 16:38:53 UTC
Thank you for the request
Comment 3 Adam Kemp 2015-05-18 16:42:33 UTC
This is not a feature request. It's a regression. It's not clear to me what this resolution means. Is it going to fixed or did it just move onto some feature backlog?