I've got a TimeSpan
with a custom format like @"hh\:mm\:ss\.fff"
, and want to use the MaskedTextBox
from xceed (https://wpftoolkit.codeplex.com/wikipage?title=MaskedTextBox&referringTitle=Home) to help the user to input a valid timespan.
Now I convert the FormatString
-Property to an input mask like this
public string InputMask
{
get
{
string mask = FormatString.Replace('h', '0');
mask = mask.Replace('m', '0');
mask = mask.Replace('s', '0');
mask = mask.Replace('f', '0');
mask = mask.Replace('d', '0');
return mask;
}
}
this solution looks ugly and not maintainable if the FormatString gets another format which I don't know yet. Is there a more elegant solution (e.g. with a regex replace), which replaces any letter with a 0
?