wp7 - view first how to tell the vm what todo

Topics: Getting Started, UI Architecture
Jun 14, 2011 at 6:35 PM


Playing around with wp7 and doing a sudoku game. My problem is how to get around how to tell the viewmodel what action to execute since it's view first I cant create the vm myself...

In the main page I want a menu with different options say "New game" or "Resume game". I still want the feeling of navigating to a new page.. So i defined my "BoardPageViewModel" as singleton so I may set properties before navigating..

    public class MainPageViewModel
        readonly INavigationService _navigationService;
        readonly BoardPageViewModel _board;
        public MainPageViewModel(INavigationService navigationService, BoardPageViewModel board)
            _navigationService = navigationService;
            _board = board;

        public void NewGame()
            _board.Board = new Board() {Id=Guid.NewGuid(), DisplayName = "Easy", Started = DateTime.Now, Cells = FakeSudokuBackend.GetBoard().ToArray()};

I know I can use WithParam to send querystring but that only handles strings. 

So I guess my question is whether there is a better way to handle this?