How to constrain a TextBox
constraints, textbox, wpf, wpf-controls
Solution
http://www.codeproject.com/KB/WPF/wpfvalidation.aspx
<TextBox Text="{Binding Path=Name}" />
And a function. This one just checks the string has content. Yours will be more complex depending on the exact format you want to enforce:
public string Name
{
get { return _name; }
set
{
_name = value;
if (String.IsNullOrEmpty(value))
{
throw new ApplicationException("Customer name is mandatory.");
}
}
}
Problem
How to set up a `TextBox` to get only certain values. e.g. `DateTime` input box with defined format settings.