I created a UWP app using TemplateStudio with MVVM-Light and can't get design data to show up in Visual Studio (or Blend).
View Model Locator:
public class ViewModelLocator
{
NavigationServiceEx _navigationService = new NavigationServiceEx();
public ViewModelLocator()
{
ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default);
if(ViewModelBase.IsInDesignModeStatic)
{
SimpleIoc.Default.Register<IFooProvider, DesignFooProvider>();
}
else
{
SimpleIoc.Default.Register<IFooProvider, FooProvider>();
}
SimpleIoc.Default.Register(() => _navigationService);
SimpleIoc.Default.Register<ShellViewModel>();
Register<MainViewModel, MainPage>();
Register<FooViewModel, FooView>();
_navigationService.SetMainViewModel(MainViewModel);
}
public MainViewModel MainViewModel => ServiceLocator.Current.GetInstance<MainViewModel>();
public ShellViewModel ShellViewModel => ServiceLocator.Current.GetInstance<ShellViewModel>();
public FooViewModel FooViewModel => ServiceLocator.Current.GetInstance<FooViewModel>();
public void Register<VM, V>() where VM : class
{
SimpleIoc.Default.Register<VM>();
_navigationService.Configure(typeof(VM).FullName, typeof(V));
}
}
FooViewModel has an ObservableCollection that is bound to in FooView.xaml
Now when I run the actual code everything runs fine and my FooViewModel correctly gets populated with data from FooProvider.
Looking at FooView though in Visual Studio or Blend, no data is displayed in the ListBox of FooView.xaml.
Is there a way to debug what's going wrong during design time? How do I fix my locator to correctly display data in FooView during design time?
(Note: The only code I added to the above class was related to FooView related items, the others were prepopulated).