I’m trying to add a new property to a Silverlight 3 custom control of mine. An int property works perfectly, but if I change it to a long or an int64, I’ve got a xaml parser exception on runtime.
Do you know if it’s a known restriction in SL3?
C# side, new control:
public class myExtTextBox : TextBox
{
public int MaxNumericValue { get; set; }
//public long MaxLongNumericValue { get; set; } => This breaks the parser
}
XAML side:
<myExtTextBox x:Name="foobar" MaxNumericValue="12" /> <!-- OK -->
<myExtTextBox x:Name="foobar" MaxLongNumericValue="12" /> <!-- Breaks parser -->
It is odd in my view that Xaml can’t parse all types that implement
IConvertible. (I’d love to know the reason if any of you MS lurkers care to edify?)Here is an implementation that may help:-
Now on the
MaxLongNumericValueproperty you use an attribute like this:-Now when the Xaml parser gets to this property it will defer to the specified
TypeConverter.