简体   繁体   中英

Platform-specific User-controls

Hello all great people in here

I am heading for creation of a Xamarin.Forms app.

I have taken a look on this link https://developer.xamarin.com/guides/xamarin-forms/custom-renderer/entry/ , where they are going to make the renderer for components platform-specific. An example can be TwinTechs Controls, which is only available for iOS and Android. How can this be done?

Is that possible? And if it, how?

The Renderer class is the custom platform-specific that you need to customize per platform.

In that particular example they are looking at changing an existing renderer.

You will be more focused in writing your own platform-specific components from scratch.

To do so you will want to inherit from ViewRenderer and supply reference to the View and also the platform-specific native element that will be the root of the control on the platform level.

Don't forget to export the renderer also, for it to be used in the rendering process of the page in Xamarin.Forms , from the platform level along the lines:-

[assembly: ExportRendererAttribute(typeof({ViewNameHere}), typeof({RendererClassNameHere}))]

There is a useful tutorial on writing custom renderers here that will help you further.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM