Best practice for Parent-Child relationship.

Oct 29, 2010 at 5:53 PM

I'm working on some software to document the version changes for our custom programs here. It has a very simple model so it seamed ideal to learn Caliburn.Micro on.  I am not 100% comfortable with WPF quite yet, so I may be missing some obvious things. 

Programs have many Versions which have many changes. I've got the ProgramViewModel set up as a Conductor.Collection.OneActive, which provides a list of current and previous Versions for the user to select from. When a version is selected, I bring up a VersionViewModel which contains a list of Changes to be viewed and edited.

The problem I'm having is with the VersionView. I've got the Changes bound to an ItemsControl, but I can not figure out how to bind the controls in the ItemsControl's Data Template to the properties of the Change without directly specifying a binding. In other words, I can't just say <Textbox x:Name="Description" /> to get at the description property of the child Change object. 

What am I doing wrong? What is the best practice for this?

Oct 29, 2010 at 10:12 PM

The conventions are not applied to elements into DataTemplates due to technical limitation: http://caliburnmicro.codeplex.com/Thread/View.aspx?ThreadId=228661

You can use the practice suggested by Rob in the same thread: use manual binding for simple templates or factor out an usercontrol for larger ones.

Oct 30, 2010 at 1:53 PM

Thanks for the information!

It would be very nice to get this in a FAQ or wiki article somewhere, as a new person to the framework, I can tell you that it is quite confusing at first blush.

Nov 10, 2010 at 3:32 PM
Edited Nov 10, 2010 at 3:36 PM
marcoamendola wrote:

The conventions are not applied to elements into DataTemplates due to technical limitation: http://caliburnmicro.codeplex.com/Thread/View.aspx?ThreadId=228661

You can use the practice suggested by Rob in the same thread: use manual binding for simple templates or factor out an usercontrol for larger ones.

For those newbies out there, including me, can you articulate just a bit on how user control's solve the problem?

Edit: O.k., I think it has everything to do with control creation interception.  Basically, user control creation can be intercepted, hence conventions possible, but no so with data templates.

 

 

Nov 10, 2010 at 5:22 PM

Yes, that is exactly the problem.