// if a left-panel button is clicked, handle the event private void ButtonClicked(object sender, RoutedEventArgs e) { // determine Button which triggered the event Button button = (Button)sender; int buttonNumber = int.Parse(button.Name.Substring(1)); // pass the number of the button to the state // if the button has any associated text it will be returned string clickedText = state.ButtonClicked(buttonNumber); // write button click text if (clickedText != null) { gc.Write(clickedText); } UpdateButtons(); }