In my Silverlight 4 application, I have a ContentControl
with its ContentTemplate
property bound to a property in the data context. That works fine. However, the content of the template once rendered has its DataContext
set to null
. I would like the content to inherit the same DataContext
as set for the ContentControl
. Is there a way to get this to happen?
views:
23answers:
1
Q:
Content generated from ContentTemplate does not have DataContext of Silverlight ContentControl set
A:
I found an alternate way to accomplish what was required. In my case, the template (not the content template) of the ContentControl
was unimportant, so I made my DataTemplate
objects into ControlTemplate
objects instead and bound the Template
property of the ContentControl
instead of ContentTemplate
. The data context was preserved if I did it this way.
Jacob
2010-07-13 19:24:11