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 for, based on the answer from Santiago below.
public DataTemplate Create(Type type)
{
return (DataTemplate)XamlReader.Load(
@"<DataTemplate
xmlns=""http://schemas.microsoft.com/client/2007"">
<" + type.Name + @" Text=""{Binding " + ShowColumn + @"}""/>
</DataTemplate>"
);
}
This works really nicely and allows me to change the binding on the fly.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…