Reputation: 28
so i have wpf mvvm project and i want to pass data between view models. i craeate the window the the xaml of the window datacontex binding call to the lactor view model
DataContext="{Binding Source={StaticResource Locator}, Path=Game }"
and this is the lactor
public ViewModelLocator()
{
ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default);
SimpleIoc.Default.Register<MainViewModel>();
SimpleIoc.Default.Register<GameViewModel>();
}
public MainViewModel Main
{
get
{
return ServiceLocator.Current.GetInstance<MainViewModel>();
}
}
public GameViewModel Game
{
get
{
return ServiceLocator.Current.GetInstance<GameViewModel>();
}
}
cant pass for example a strig from main view model to game view model how can i do it ? thaks all
Upvotes: 0
Views: 33