I use the DesignData functionality in SilverLight to display data in the visual xaml editor while I’m designing the layout. However, the converters I use in the layout during binding expect a type of X but instead receive a type of some ‘behind the scenes’ generated design class _.di0.X during the design phase.
What is the best way to handle this situation? At this point I throw an exception when the converter doesn’t receive a type of X and therefore the application crashes.
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var myObj = value as X;
if (myObj != null)
{
// bla bla
}
throw new ArgumentException("value was of type " + value.GetType() + " must be of type X", "value");
}
I am guessing the exception is causing you issues? i.e. causing the page to not render in Visual Studio. What you can do is detect whether you are in design mode then employ some different logic:
What you do, is up to you! Perhaps use reflection on the generated types that has been passed?