Here is the problem:
I have a property of a certain object. This property is of Type t. I need to find out, if a string value can be attached to this property.
For example: I have an instance of a Windows.Controls.Button. I need a mechanism, that will return true for property Button.Background, but false for Button.Template.
Can anybody help? Thanks a lot
I think you take the problem in the wrong direction :
The property does not accepts directly String: actually the property is converted to the good type if a converter exists.
You then may look if a converter exist using this code :
public static bool PropertyCheck(Type theTypeOfTheAimedProperty, string aString)
{
// Checks to see if the value passed is valid.
return TypeDescriptor.GetConverter(typeof(theTypeOfTheAimedProperty))
.IsValid(aString);
}
These pages may interest you too :