bool IsAllowedType (XamlType xt, object value)
{
return xt == null ||
xt.UnderlyingType == null ||
xt.UnderlyingType.IsInstanceOfType (value) ||
value == null && xt == XamlLanguage.Null ||
xt.IsMarkupExtension && IsAllowedType (xt.MarkupExtensionReturnType, value);
}