0

Hi I am working with WPF PRISM architecture.

I have two usercontrols: UCParent--UCParentVM UCChild -- UCChildVM Both have their own viewmodels. Now that I have injected UCChild into UCParent. But I want to access a property ("UCParent.DataContext.ProeprtyForChild") in the Parent usercontrol UCParent. How do I able to get the parent's DataContext.Property?

I Tried some relative source and element name binding. I think i am getting them completely wrong. So any clues?

Thanks in advance

WPFKK
  • 1,419
  • 3
  • 20
  • 42
  • Something sounds wrong here. For example, if a control is bound to an Object which contains a property of another object you can simply do: Property.SubProperty. If you have an ItemsControl, ItemsSource is set to a List of Objects and the ItemTemplate's DataContext is automatically the Object. But, you have a **Control** inside a control. You want the parent control, to modify the child controls datacontext? This sounds like a violation of MVVM. The VM of the Parent, would perhaps relate to the Child VM and interact with it directly? The link shouldn't go through UI controls? – Alan Oct 31 '12 at 14:29
  • I think your question has your parent and child crossed a few places. If you can clean that up you can probably get a better answer. (For Example you say you want to "access UCParent.DataContenct.PropertyForChild in UCParent" That would be done via a simple binding: {Binding PropertyForChild}) – Vaccano Nov 01 '12 at 05:41
  • @vaccano: I am trying to access parents property in Child so I should locate parents DataContext and then look for the Property "PropertyForChild" – WPFKK Nov 04 '12 at 23:39

0 Answers0