Uri property in a Silverlight 2 UserControl
In creating a Silverlight 2 UserControl, I had a need to include a Uri parameter, so I added a property.
class MyControl : UserControl
{
...
public Uri Source {get;set;}
...
}
That compiled and ran just fine but when I tried to set the value via XAML, I got an AG_E_PARSER_BAD_PROPERTY_VALUE error. The property was missing a type converter, a class that converts between a string and the property value. I added a using directive and the attribute to the property specifying to use the built-in UriTypeConverter:
using System.ComponentModel;
class MyControl : UserControl
{
...
[TypeConverter(typeof(UriTypeConverter))]
public Uri Source {get;set;}
...
}
That fixed it!