public StartViewModel(Game game) { this.currentGame = game; this.players = new ObservableCollection<PlayerViewModel>(); foreach (Player p in this.currentGame.Players) { this.players.Add(new PlayerViewModel(p, null)); } //this.collectionView = CollectionViewSource.GetDefaultView(this.players); //if (this.collectionView == null) // throw new NullReferenceException("collectionView"); }
public GameViewModel(Game game) { this.currentGame = game; this.players = new ObservableCollection<PlayerViewModel>(); foreach (Player p in this.currentGame.Players) { this.players.Add(new PlayerViewModel(p, this)); } this.collectionView = CollectionViewSource.GetDefaultView(this.players); if (this.collectionView == null) throw new NullReferenceException("collectionView"); this.collectionView.CurrentChanged += new EventHandler(this.OnCollectionViewCurrentChanged); }
public MainWindow() { InitializeComponent(); Game game = new Game(); StartViewModel startViewModel = new StartViewModel(game); startViewModel.CurrentGame = game; this.DataContext = startViewModel; GameViewModel gameViewModel = new GameViewModel(game); this.GameView.DataContext = gameViewModel; this.CategoryView.DataContext = gameViewModel; Questions questions = new Questions(); QuestionsViewModel questionsViewModel = new QuestionsViewModel(questions); this.QuestionsView.DataContext = questionsViewModel; this.QuestionsOpenView.DataContext = questionsViewModel; // this.DataContext = gameViewModel; }
private void ResetGame() { this.currentGame = new Game(); }