In Silverlight 4, I would like to be able to pick from a dynamic list of UserControls and then display the full control after selection.
Meanwhile, in the list of UserControl options, I would like to display something more interesting than just a label or a scaled-down version of the UserControl’s graphics. I would like to display a custom “thumbnail” that is defined in the control and exposed via a property that returns a UIElement (or straight XAML string).
So far I have attempted to draw the thumbnail within the XAML of the UserControl and expose that via a property as a UIElement. It has not worked for me (I get some sort of Silverlight rendering error). Is there a way to instead return the XAML of a child control as a string?
I imagine some solution like
XamlWriter.Write(UIElement);
It is key for me to be able to programmatically write the XAML of a control so that it can be designed in Blend.
It turns out this question is similar to the one asked here.
I have since found out that WPF includes a XamlWriter class with a Save method that does exactly what I want. Unfortunately, it is not included in Silverlight.
I ended up using the XamlWriter class that was created in the Silverlight Contrib project. It allows me to easily generate a string of XAML by referencing any UIElement.