0

I have a Xamarin Forms Application with MvvmLight using the Service Locator Pattern. The ViewModelServiceLocator itself is a static class with access to a Autofac container with all dependencies registered. For each VM there is static property:

    public static AboutViewModel AboutVm => ServiceLocator.Current.GetInstance<AboutViewModel>();

I have the Locator setup as in my App as a resource follows:

<presentation:ViewModelLocator x:Key="Locator" />

And in my xaml on my page:

BindingContext="{Binding AboutVm, Source={StaticResource Locator}}"

But the Locator is never called. But it does work, when I set it up in the code behind via

BindingContext = ViewModelLocator.AccountListVm;

Do I miss a resource definition or something?

NPadrutt
  • 3,619
  • 5
  • 24
  • 60
  • Can you try give a path as mentioned in [this thread](https://stackoverflow.com/questions/936304/binding-to-static-property)? – nevermore Jun 20 '19 at 06:44
  • It does work when I use the static reference. But it would be nice to have the option to have it via the resource, so it is identical to UWP. – NPadrutt Jun 21 '19 at 17:14

0 Answers0