Hi,@fatih uyanık. For entering date in TextBox, automatically add .
, you could refer to the following code.
<TextBox x:Name="textBox" TextChanged="DateTextBox_TextChanged" Height="50" Background="Beige"/>
Codebedhind:
private void DateTextBox_TextChanged(object sender, TextChangedEventArgs e)
{
if (sender is TextBox textBox)
{
var text = textBox.Text.Replace(".", "");
if (text.Length >= 2 && text.Length < 4)
{
textBox.Text = text.Insert(2, ".");
textBox.Select(textBox.Text.Length, 0);
}
else if (text.Length >= 4)
{
textBox.Text = text.Insert(2, ".").Insert(5, ".");
textBox.Select(textBox.Text.Length, 0);
}
}
}
The result:
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.