You need to expose the new game list view model to the user. Try it yourself before reading on.

Got it? Good. Add a UserControl to Lesson.Client and name it "GameListControl". Add the opponent text box, the Challenge button, and the list of active games.
            Text="{Binding Opponent, UpdateSourceTrigger=PropertyChanged}" />
            Command="{Binding Challenge}">Challenge</Button>
            ItemsSource="{Binding ActiveGames}" />
Add this control to the main window.
        DataContext="{Binding MachineVM}" />
        DataContext="{Binding GameListVM}" />
    <TextBox />
Then add the GaleListVM property to the main view model.
private GameListNavigationModel _gameListNavigationModel = new GameListNavigationModel();

public GameListViewModel GameListVM
        LogOn currentLogOn = _machine.LogOns.FirstOrDefault();
        return currentLogOn == null
            ? null
            :  new GameListViewModel(currentLogOn.User, _gameListNavigationModel);
Run it and see how it behaves. You can log on and add a game, but it doesn't properly display the opponent's name. Add an item template to fix that.
    ItemsSource="{Binding ActiveGames}">
                Text="{Binding OpponentName}" />
Now it looks right. You'll need to use your designer and XAML skills to make it look good.

Next: Lesson 3a: Negative facts

Last edited Aug 8, 2010 at 5:35 PM by MichaelLPerry1971, version 2


No comments yet.