I have the following simple TextBox subclass, which adds one dependency property (OutputIndex):
public class OutputTextBox : TextBox
{
public OutputTextBox() : base() { }
public int OutputIndex
{
get { return (int)this.GetValue(OutputIndexProperty); }
set { this.SetValue(OutputIndexProperty, value); }
}
public static readonly DependencyProperty OutputIndexProperty = DependencyProperty.Register(
"OutputIndex",
typeof(int),
typeof(OutputTextBox),
new PropertyMetadata(false));
}
When I try to instantiate an instance of OutputTextBox, like
OutputTextBox otb = new OutputTextBox();
I get a System.TypeInitializationException thrown with the InnerException saying: "Default value type does not match type of property 'OutputIndex'."
What 'Default value type' is the InnerException referring to? What do I need to do to be able to instantiate an instance of OutputTextBox?