silverlight 文本框只能输入汉字
private void txtName_KeyDown(object sender, KeyEventArgs e) { Regex rg = new Regex("^[\u4e00-\u9fa5\b]$"); //\b是退格键 if (!rg.IsMatch(e.Key.ToString())) { e.Handled = true; } if (txtName.Text.Length >= 20) { txtName.Text = txtName.Text.Substring(0, 20); EasySL.Controls.Window.Alert("请输入20内的名称", this.floatePanel); } }