は、私は現在
<TextBox Height="22" HorizontalAlignment="Left" Margin="192,118,0,0" Name="Unit_ID" VerticalAlignment="Top" Width="173" PreviewTextInput="UnitID_PreviewTextInput" TextInput="Unit_ID_TextInput" TextChanged="Unit_ID_TextChanged" />
XAML
数値のみテキストボックス
を作成するには、このコードを使用しています
とth EのC#の分離コード
private void UnitID_PreviewTextInput(object sender, TextCompositionEventArgs e)
{
foreach (char c in e.Text)
if (!Char.IsDigit(c))
{
e.Handled = true;
break;
}
が独占的XAMLを使用してこれを行うことが可能です?私はあなたができる、これを成し遂げるために、純粋なHTMLを使用することはできません同じように
私はあなたがバリデーションを探していると思います。 googleの "検証のwpf" http://stackoverflow.com/questions/1346707/validation-in-textbox-in-wpf – JSJ
http://stackoverflow.com/questions/1268552/how-do-i-get-a -textbox-to-only-accept-numeric-in-wpfには役に立つヒントがあります。 – weeyoung