You can easily reproduce the bug.Just inherit the DataTemplate and use the new DataTemplate class instead of default.You will get an runtime exception.
Your DataTemplate class
Nothing unusual rite? Then use this DataTemplate in your XAML.
Just using the new class.But when we run this we get the exception as follows.
StackPanel' object cannot be added to 'MyDataTemplate'. Object of type 'System.Windows.Controls.StackPanel' cannot be converted to type 'System.Windows.FrameworkElementFactory.
This is true same in the case of HierarchicalDataTemplate too.
This is an identified bug.Microsoft has fixed this and WPF 4 contains the fix.