private void Button_Click(object sender, RoutedEventArgs e) { string temp = ((Button)sender).Name; if (temp == "Play") { temp = _model.UserSelection(temp); } else { var selectedButton = e.OriginalSource as FrameworkElement; if (selectedButton != null) { var currentTile = selectedButton.DataContext as Tile; temp = _model.UserSelection(currentTile.TileName); } } }
private void Button_Click(object sender, RoutedEventArgs e) { var selectedButton = e.OriginalSource as FrameworkElement; if (selectedButton != null) { var currentTile = selectedButton.DataContext as Tile; _model.UserSelection(currentTile.TileName); } }
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; _model.UserSelection(currentTile.TileName); } }