Hello,
Welcome to our Microsoft Q&A platform!
You create a custom renderer for Xamarin.Forms.View
, but the Xamarin.Forms.View
's renderer base class is IViewRenderer
, not the SurfaceViewRenderer
, when you create custom renderer, so you will get the System.InvalidCastException: 'Specified cast is not valid.'
To create a cameraView with custom renderer view, You can refer to following thread:
https://learn.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/custom-renderer/view
Here is source code.
If you want to create a custom renderer for xamarin forms controls, you should refer this thread to get the renderer base class and Native Controls, then create a custom renderer for your control.
:https://learn.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/custom-renderer/renderers
Best Regards,
Leon Lu
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.