I created a custom control called RegexTextBox which derives from TextBox. To this I added a Regex dependency property. All of this works fine.
Next thing I created a NumericUpDown button control based upon the NumericUpDown in Kevin's WPF Bag-o-Tricks. I replaced the default TextBox with my RegexTextBox and added 3 more dependency properties to my NumericUpDown control.
One dependency property called Regex (string) to forward the Regex I want to use. One dependency property called Format (string) which I'd like to use as a ConverterParameter. One dependency proprety called ValueConverter (IValueConverter) which I'd like to use to set the required IValueConverter.
In my NumericUpDown control I used the following setup for my TextBox:
<local:RegexTextBox
VerticalAlignment="Stretch"
TextWrapping="Wrap"
Foreground="White"
HorizontalContentAlignment="Center"
VerticalContentAlignment="Center"
BorderThickness="0"
RegularExpression="{TemplateBinding Regex}"/>
I don't now how to add my converter to the Text property though. I now I can use something like Text="{Binding RelativeSource={RelativeSource TemplateParent} Path=Value}"
and I now how to add a static resource as the Converter but how do I get the converter and argument from my template parent?
I'm also not sure whether IValueConverter is the correct type for the ValueConverter dependency property as Expression Blend gave some errors about string conversion.