How do I create a silverlight data template in code? I\'ve seen plenty of examples for WPF, but nothing for Silverlight.
Edit: Here\'s the code I\'m now using this f
Although you cannot programatically create it, you can load it from a XAML string in code like this:
public static DataTemplate Create(Type type)
{
return (DataTemplate) XamlReader.Load(
@"
<" + type.Name + @"/>
"
);
}
The snippet above creates a data template containing a single control, which may be a user control with the contents you need.