Forum Xamarin.Android

IViewModelStoreOwner not implimented in AppCompatActivity

I'm a bit lost, I am trying to implement the ViewModelProvider in Xamarin.Android but it seems like IViewModelStoreOwner is not implemented by AppCompatActivity

C# Code

 var androidViewModelFactory = ViewModelProvider.AndroidViewModelFactory.GetInstance(Application);

                var viewmodelprovider =
                    new ViewModelProvider(this, androidViewModelFactory); **// this=AppCompatActivity does not impliment IViewModelStoreOwner** 

                var vm = (CameraXViewModel)viewmodelprovider.Get(cameraXViewModel.Class);
Java Code

  new ViewModelProvider(this,androidViewModelFactory ) /**/ this =AppCompatActivity javacode implimenents ViewModelStoreOwner Interface**   
                provider -> {
                  cameraProvider = provider;
                  if (allPermissionsGranted()) {

Therefore I cannot implement ViewModelProvider in Xamarin.Android

What am I missing?

Thanks in advance

Sign In or Register to comment.