We are making a project where we have one page of our WPF application which will choose a save game out of three, and then it navigates to the next page. We whould like to know how to pass the GameInstance we load from the first page, to the second.
We have already implemented this in the Code Behind, but we dont like having logic in code behind, since we are using the MVVM architecure.
Code Behind of save window
public SaveGameWindow()
{
InitializeComponent();
}
private void LoadGame1_Click(object sender, RoutedEventArgs e)
{
var comb = new SaveGameViewModel();
comb.LoadGame1();
this.NavigationService.Navigate(comb.TempCombatWindow);
}
private void LoadGame2_Click(object sender, RoutedEventArgs e)
{
var comb = new SaveGameViewModel();
comb.LoadGame2();
this.NavigationService.Navigate(comb.TempCombatWindow);
}
private void LoadGame3_Click(object sender, RoutedEventArgs e)
{
var comb = new SaveGameViewModel();
comb.LoadGame3();
this.NavigationService.Navigate(comb.TempCombatWindow);
}
What we would like to know, is how to implement the same thing as above, but in our ViewModel for the save game.
The issue is when we change pages, we use the NavigationService, but this is not available in the ViewModel, and we have not found a way to bind this property to said ViewModel so we can use some kind of delegate.
I hope the question was not to confusing.