public static string TextTrimmed(this System.Windows.Controls.TextBox textbox) { string sText = textbox.Text; if (String.IsNullOrEmpty(sText)) { return ""; } else { return sText.Trim(); } }