private void SpeechPopup_CancelButton_Click(object sender, RoutedEventArgs e) { switch (speechState) { case SpeechHelper.SpeechState.Initializing: case SpeechHelper.SpeechState.Listening: case SpeechHelper.SpeechState.Recognizing: // user tapped the cancel button // cancel the current operation / close the socket to the service SpeechHelper.Cancel( new MainViewModel.NetworkOperationInProgressCallbackDelegate(SpeechPopup_NetworkOperationInProgressCallBack)); // reset the text in the textbox QuickAddPopupTextBox.Text = ""; break; case SpeechHelper.SpeechState.Finished: // user tapped the OK button // set the text in the popup textbox QuickAddPopupTextBox.Text = SpeechLabelText.Trim('\''); break; } SpeechPopup_Close(); }