重複の可能性:
WPF のテキスト ボックスでの検証
現在、このコードを使用して数値のみのテキストボックスを作成しています
Xaml
<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" />
および C# コードビハインド
private void UnitID_PreviewTextInput(object sender, TextCompositionEventArgs e)
{
foreach (char c in e.Text)
if (!Char.IsDigit(c))
{
e.Handled = true;
break;
}
XAML を排他的に使用してこれを行うことは可能ですか?.cs ファイルを最小化しようとしています。