

Creating a Native View from a Xamarin.Forms View
source link: https://michaelridland.com/xamarin/creating-native-view-xamarin-forms-viewpage/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Creating a Native View from a Xamarin.Forms View
WARNING: this is a expert level technique and isn’t officially supported by Xamarin.
Personally I feel like this is the holy grail of Xamarin.Forms development, having the ability to jump between both Xamarin.Forms Views and Native Views. I’ve used this technique multiple times in Xamarin.Forms apps.
It’s primarily used when you’ve created a custom renderer and you’re working against Native UI APIs, this could be in the native maps API or a 3rd party native component. Now once you’re in the Native area of the application there’s cases where you need to show a view for the user but you still want to have the View shared between the platforms.
To give you an idea the structure might be as follows.

In the diagram above the secret sauce is in orange, taking a Xamarin.Form View and converting that into a native view. This converts to a UIView in iOS and ViewGroup in Android.
Below I’ve written two helper classes that take a Xamarin.Forms view and convert it into the NativeViews. In my experience this code works the best when the Xamarin.Forms view is a Layout.
iOS Converter Class
Android converter class
I’ve created a github sample application, please find it https://github.com/rid00z/LoadingFormsViewFromNative. *** Please note this iOS project uses UIPopover which is only available on iPad so you must use the iPad for this demo.
If you want to know more awesome Xamarin.Forms techniques then my eCourse is a must do! ‘Secrets of a Xamarin.Forms Ninja‘
Thanks
Michael
Recommend
-
105
-
67
Change Randomly A View’s Color Hi everyone, here is the third part of the Xamarin Forms Tips series. Today, we will look at how to change a...
-
42
Snack Bar in Xamarin Forms Hello friends, notifying users about what happens in your mobile application is necessary. There is the
-
42
Creating a Bottom Drawer in Xamarin.Forms721 views•Jan 19, 2021590ShareSave
-
31
Create a Wizard View in Xamarin.Forms: A Novice’s GuideA wizard control is an interactive, customizable user interface that can hold more than one page. It is useful in showcasing step-by-step processes, and als...
-
39
Creating a Floating Label Layout in Xamarin.Forms DataFormThe Syncfusion Xamarin.Forms DataForm supports a floating label layout that...
-
8
#XamarinEssentials #Maps #XamarinFormsOpen Native Maps Apps with Xamarin.Essentials and Xamarin.Forms
-
11
Creating a custom control is a common thing to do when developing a Xamarin Forms application. In many cases, the main purpose of creating one is to have a reusable control that we can use across all our application. In this articl...
-
15
.NET Development Addict Home is where the [.net] compiler is. Xamarin.Forms is really cool! It allows you to almost write y...
-
25
Page thumbnails are miniature previews of the pages in a document. You can use page thumbnails to navigate to a required page quickly. We can achieve the thumbnail view at the application level by exporting PDF pages as images.In this blog,...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK