Last active
May 6, 2020 06:53
-
-
Save lubiepomaranczki/844ec05a225804545c68d908043e08f3 to your computer and use it in GitHub Desktop.
Solution proposed by Ryan Davis to the problem described here https://twitter.com/lawiluk/status/1257661151258820608 . This sample is for MVVMCross but you should be fine with other Frameworks.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class FormsTestView : BaseViewController<FormsTestViewModel> | |
{ | |
public override void ViewDidLoad() | |
{ | |
base.ViewDidLoad(); | |
EdgesForExtendedLayout = UIRectEdge.None; | |
Xamarin.Forms.Forms.Init(); | |
var page = new FormsTestPage { BindingContext = ViewModel }; | |
var formsViewController = page.CreateViewController(); | |
var nativeView = formsViewController.View; | |
nativeView.TranslatesAutoresizingMaskIntoConstraints = false; | |
formsViewController.WillMoveToParentViewController(this); | |
formsViewController.ViewWillAppear(true); | |
View.Add(nativeView); | |
nativeView.LeftAnchor.ConstraintEqualTo(View.LeftAnchor).Active = true; | |
nativeView.TopAnchor.ConstraintEqualTo(View.TopAnchor).Active = true; | |
nativeView.RightAnchor.ConstraintEqualTo(View.RightAnchor).Active = true; | |
nativeView.BottomAnchor.ConstraintEqualTo(View.BottomAnchor).Active = true; | |
formsViewController.ViewDidAppear(true); | |
formsViewController.DidMoveToParentViewController(this); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment