private void Button_Click(object sender, RoutedEventArgs e) { // one of the buttons in our collection. need to figure out // which one. Since we know the button is part of a collection, we // have a special way that we need to get at its if (_model.Active && _model.MyTurn && _model.Connected) { var selectedButton = e.OriginalSource as FrameworkElement; if (selectedButton != null) { // get the currently selected item in the collection // which we know to be a Tile object // Tile has a TileName (refer to Tile.cs) var currentTile = selectedButton.DataContext as Tile; if (_model.UserSelection(currentTile.TileName, _model.Piece)) { _model.SendMove(currentTile.TileName, false); _model.MyTurn = false; } } } }