• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 360
  • Last Modified:

Binding to a method from a DataTemplate

I have the following setup.

Case (object of type Case)
---> CaseNumber
---> GetRecipients() (returns a List<Recipient>

Recipient
---> RecipientNumber
---> GetACWM()   (returns one object of type ACWM)

I have an ItemsControl that I am binding to Case (working fine), the DataTemplate for Case has an ItemsControl that I am binding to the GetRecipients() method (also working fine).  This bind is working because I set the ObjectInstance of my ObjectDataProvider (for Case) in the code behind when the case is provided.  I cannot do the same things for recipient because there are multiple recipients in a case.  So, in the recipient DataTemplate I  have an ObjectDataProvider (for Recipient).  How can I set the ObjectInstance of this ODP to the current recipient being bound?

I hope this was clear enough.
0
jmwheeler
Asked:
jmwheeler
1 Solution
 
mikebirtCommented:
Hi,

I'm not sure you can set the ODP instance from within your provider. However, could you not combine your providers into a  single provider and expose two properties, the recipients in one property and a property that indexes the recipients collection itself as your selected recipient?

HTH

Mike
0
 
jmwheelerAuthor Commented:
I was able to find a different way around.  I just made the recipient a separate control with a dependency property that gets set with the current instance of Recipient.  When the property is set I set other ODP's on the new Recipient Control with the recipient instance provided.

Thank you though.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now