Link to home
Start Free TrialLog in
Avatar of jmwheeler
jmwheeler

asked on

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.
Avatar of mikebirt
mikebirt
Flag of United Kingdom of Great Britain and Northern Ireland image

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
ASKER CERTIFIED SOLUTION
Avatar of jmwheeler
jmwheeler

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial