How do I derive a new class from DataTemplate and then use it in place of DataTemplate?
For example, in C#:
public class DerivedDataTemplate : DataTemplate
{
}
Then in XAML:
<local: DerivedDataTemplate DataType="{x:Type local:SomeType}">
<Grid>
... UI here ...
</Grid>
</local:DerivedDataTemplate>
When I try to use my derived data template class the follow exception is generated:
System.Windows.Markup.XamlParseException was unhandled Message="'Grid' object cannot be added to 'DerivedDataTemplate'. Object of type 'System.Windows.Controls.Grid' cannot be converted to type 'System.Windows.FrameworkElementFactory'.
Does anyone know how to work around this exception and successfully use a class derived from DataTemplate?