private void btnEdit_Click(object sender, RoutedEventArgs e) { Button button = (Button)sender; var currentGame = (GameInfo)button.DataContext; WindowGameEdit windowGameEdit = new WindowGameEdit(context, currentGame); windowGameEdit.Show(); }