Hi Rachana,
You simply reached the limit of what can be done when trying to build templates through code...
Here is an excerpt of the MSDN documentation regarding the creation of templates through code:
Remarks regarding FrameworkElementFactory:
This class is a deprecated way to programmatically create templates, which
are subclasses of FrameworkTemplate such as ControlTemplate or DataTemplate; not all of the
template functionality is available when you create a template using this class.
The recommended way to programmatically create a template is to load XAML from a
string or a memory stream using the Load method of the XamlReader class.
Marc Laroche
Software Developer
Xceed Software Inc.I don’t suffer from insanity, I enjoy every minute of it. - Unknown