I create some xaml in the template class, and I need a rectangle to have the Fill property set by something coming from a text field filled in by the end user. So I need to check that the value is converted to a Brush object before xaml output. Otherwise, if the value is not a valid color (with or without a name), I get the following: Error: Sys.InvalidOperationException: Invalid XAML for the 'sldivparent' control. [] (line 6, col 412): Failed to create "System.Windows.Media.Brush" from the text "NotValidColorValue". Obviously, I don't want this, and in the case of an invalid value, I just want it to be white.
So, how can I make sure that “NotValidColorValue” is a valid color value before continuing?
thank
Edit for further clarification: I use the color picker, invoking the silverlight YUI color picker shortcut to be precise, and its performance. The fact is that the user can also enter a color (either # 112233 or "red") directly into the text field, and it must be valid or display white if it is invalid. I don’t want to go to all the manual checking of color names, so ideally I would like to try to create an object of some type (possibly some Brush derivative) using any user, typing it, and if that fails, I would know the color value is invalid and acts accordingly.
source
share