Exemplo n.º 1
0
        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 bame

            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.Switch_side();
                    _model.Win();
                }
            }
        }