Can conventions work with DataTemplates for collection items??

Apr 4, 2011 at 4:15 PM


Quick Question: I have a TextBox within a DataGridTemplateColumn.  Is there a way to use the conventions to get this to Bind correctly as the property i'm binding to is on an object in a collection. The collection is a child of a property defined on the ViewModel . Is this possible?

Best Regards

Apr 4, 2011 at 4:34 PM

Unfortunately no. We cannot automatically apply conventions in templates because the underlying platform does not give us a "hook" we can use to do it. I normally use regular databinding expressions in small data template or break out a user control for complex templates. You can tell the framework to apply conventions manually be adding a ca:Bind.Model="{Binding}" to the root node in the template. But, I usually just use this with complex templates. You can read a little bit ore about the various options here in the section on View-First.

Apr 4, 2011 at 4:42 PM

Didnt think so,thought I'd ask the question though.

Thanks for the quick reply Rob