//http://www.michaelridland.com/xamarin/creating-native-view-xamarin-forms-viewpage/ private ViewGroup ConvertFormsToNative(Xamarin.Forms.View view, Rectangle size) { var vRenderer = Platform.CreateRenderer(view); var viewGroup = vRenderer.ViewGroup; vRenderer.Tracker.UpdateLayout(); var layoutParams = new ViewGroup.LayoutParams((int)size.Width, (int)size.Height); viewGroup.LayoutParameters = layoutParams; view.Layout(size); viewGroup.Layout(0, 0, (int)view.WidthRequest, (int)view.HeightRequest); return(viewGroup); }
public static View ConvertFormsToNative(this Xamarin.Forms.View view, Context context, Rectangle size) { var vRenderer = Platform.CreateRendererWithContext(view, context); var viewGroup = vRenderer.View; vRenderer.Tracker.UpdateLayout(); var layoutParams = new ViewGroup.LayoutParams((int)size.Width, (int)size.Height); viewGroup.LayoutParameters = layoutParams; view.Layout(size); viewGroup.Layout(0, 0, (int)view.WidthRequest, (int)view.HeightRequest); return(viewGroup); }