Xamarin.Forms Page wrappers for MvvmCross the Android Fragment/Activity and the iOS ViewController
Inspired by Alex Dunn's blog posts:
Wraps a Xamarin.Forms Page inside a MvvmCross view. This allows for "native" navigation via MvvmCross. The result is that you can easily navigate between a native view and a embedded Xamarin.Forms page.
MvxEmbeddedContentPage
.2a. In your Android project, create a MvxFormsActivity
or MvxFormsFragment
to wrap your Xamarin.Forms page.
public class MyFormsFragment : MvxFormsFragment<MyPage, MyViewModel>
{
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
Page.BackgroundColor = Color.Red;
...
}
}
2b. In your iOS project, create a MvxFormsViewController
to wrap your Xamarin.Forms page.
public class MyFormsViewController : FormsViewController<MyPage, MyViewModel>
{
public override void ViewDidLoad()
{
base.ViewDidLoad();
Page.BackgroundColor = Color.Red;
...
}
}
You can override the CreatePage method to handle the construction of the page.
protected override MyPage CreatePage()
{
return new MyPage(paramter1, parameter2)
{
ViewModel = ViewModel
};
}
You can override the Frame
that the MvxEmbeddedContentPage
is embedded into.
protected override UIView FragmentLayoutId()
{
return Resource.Id.some_other_frame;
}
You can override the UIView
that the MvxEmbeddedContentPage
is embedded into.
protected override UIView PageContainerView()
{
return _someOtherView;
}