I need to create a mobile app that have to run on android 7.0 - 9.0 and the latest iOS
So in my VS 2017 15.9.6 on Windows 10 I try to use Xamarin.Forms 3.4 in a shared project as a container for a native Android.VideoView.
I try to figure out how to do that, since the Mono.Android examples don't use Xamarin.Forms. So, do I need a kind of #ifdef in the xaml file, to embedd ths Android VideoView? Or am I completely wrong with that approach?
Using a Shared Projects, you can define the native views in XAML and then access them in the code behind (which is basically a requirement since native Android|iOS controls are not directly bindable and most have method calls for setting up features that would not available via XAML (i.e. a VideoView has a
.SetVideoURI
method that has no Xamarin-based wrapper property so you have to execute that method to play a video).XAML:
Note: Do not enable
XamlCompilation
at the global assembly level or on XAML pages that contain native views as it will not work (and there are not errors during compiling or runtime, the views just do not show up as they have been stripped out)...MainActivity
Code Behind: