Я пытаюсь преобразовать свое приложение Windows Phone 8 Silverlight в приложение 8.1 Phone как часть универсального приложения. Я не знаю, актуально ли это, потому что я впервые пытаюсь правильно реализовать модели представления. Я хочу обмениваться данными между представлениями в Windows и Windows Phone. Во всяком случае, это ошибка, которую я получаю.
Error 3 Type not found in cache: ScoreAlerts.ViewModel.FixturesViewModel. C:\Users\Dave\Documents\Visual Studio 2012\Projects\Score Alerts\ScoreAlerts\ScoreAlerts.WindowsPhone\Pages\Fixtures.xaml 9 5 ScoreAlerts.WindowsPhone
Error 4 Type not found in cache: ScoreAlerts.ViewModel.HomePageViewModel. C:\Users\Dave\Documents\Visual Studio 2012\Projects\Score Alerts\ScoreAlerts\ScoreAlerts.Shared\Pages\HomePage.xaml 34 9 ScoreAlerts.WindowsPhone
Вот как выглядит мой локатор модели представления
public class ViewModelLocator
{
/// <summary>
/// Initializes a new instance of the ViewModelLocator class.
/// </summary>
public ViewModelLocator()
{
if (!ViewModelBase.IsInDesignModeStatic)
{
ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default);
if (ViewModelBase.IsInDesignModeStatic)
{
// Create design time view services and models
//SimpleIoc.Default.Register<IDataService, DesignDataService>();
}
else
{
// Create run time view services and models
//SimpleIoc.Default.Register<IDataService, DataService>();
}
SimpleIoc.Default.Register<HomePageViewModel>();
SimpleIoc.Default.Register<FixturesViewModel>();
}
}
[SuppressMessage("Microsoft.Performance",
"CA1822:MarkMembersAsStatic",
Justification = "This non-static member is needed for data binding purposes.")]
public HomePageViewModel Main
{
get
{
//return ServiceLocator.Current.GetInstance<HomePageViewModel>();
return SimpleIoc.Default.GetInstance<HomePageViewModel>("default");
}
}
[SuppressMessage("Microsoft.Performance",
"CA1822:MarkMembersAsStatic",
Justification = "This non-static member is needed for data binding purposes.")]
public FixturesViewModel Fixtures
{
get
{
//return ServiceLocator.Current.GetInstance<FixturesViewModel>();
return SimpleIoc.Default.GetInstance<FixturesViewModel>("default");
}
}
public static void Cleanup()
{
// TODO Clear the ViewModels
}
}
Мой взгляд XAML имеет это
DataContext="{Binding Fixtures, Source={StaticResource Locator}}"
и в моем приложении есть это
<viewModel:ViewModelLocator x:Key="Locator"
d:IsDataSource="True"/>
Любые идеи, что я делаю неправильно?