private void Button_Click_1(object sender, RoutedEventArgs e) { Button but = sender as Button; vm.reason = but.Content as string; string message = vm.saveQCS(Barcode.Text, vm.reason); if (message != string.Empty) { Errormsg.Text = message; ErrorTxt.Visibility = Visibility.Visible; return; } print popup = new print(); popup.ShowDialog(); Barcode.Text = ""; Barcode.Focus(); BarcodeChars = 0; }