0
我想知道是否有什麼東西接近Xamarin Forms中的KeyPressEventArgs,因爲我需要驗證一些字段。這裏是一個Windows窗體的例子。Xamarin.Forms/KeyPressEventArgs
public static bool ValideringTlf(KeyPressEventArgs e)
{
return (e.Handled = char.IsNumber(e.KeyChar) || e.KeyChar == 8 || e.KeyChar == 127 ? false : true);
}
public static bool ValideringNavn(KeyPressEventArgs e)
{
return (e.Handled = char.IsLetter(e.KeyChar) || e.KeyChar == 8 || e.KeyChar == 32 || e.KeyChar == 127 ? false : true);
}
public static bool ValideringVejnr(KeyPressEventArgs e)
{
return (e.Handled = char.IsNumber(e.KeyChar) || char.IsLetter(e.KeyChar) || e.KeyChar == 8 || e.KeyChar == 127 ? false : true);
}
public static bool ValideringPostnr(KeyPressEventArgs e)
{
return (e.Handled = char.IsNumber(e.KeyChar) || e.KeyChar == 8 || e.KeyChar == 127 ? false : true);
}
這些數字來自Ascii Tabel。