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**   
            .get(CameraXViewModel.class)
            .getProcessCameraProvider()
            .observe(
                this,
                provider -> {
                  cameraProvider = provider;
                  if (allPermissionsGranted()) {
                    bindAllCameraUseCases();
                  }
                });

Therefore I cannot implement ViewModelProvider in Xamarin.Android

What am I missing?

Thanks in advance

Sign In or Register to comment.