【发布时间】:2020-03-18 13:14:37
【问题描述】:
您好,我在使用这些代码时遇到问题:
private void OnlyText(object sender , TextCompositionEventArgs e)
{
Regex regex = new Regex("^[a-zA-Z]+$");
e.Handled = regex.IsMatch(e.Text);
}
XAML
<TextBox PreviewTextInput="OnlyText" x:Name="tbSurrname" HorizontalAlignment="Left" Height="23" TextWrapping="Wrap" Text="Nazwisko" VerticalAlignment="Top" Width="120" Margin="81,137,0,0"/>
只允许 wpf 文本框使用字母字符,但它没有任何解决方案?
【问题讨论】:
-
所以您不能在框中输入自己的姓氏?世界不会只说 a-z。