I have custom control (FooCtrl) and it has 4 DependencyProperties (Q1, Q2, Q3 and Q4).
public partical class FooCtrl : UserControl {
// ...
// Q1:
public static readonly DependencyProperty Q1Property =
DependencyProperty.Register("Q1", typeof(UIElement), typeof(FooCtrl), new UIPropertyMetadata(null));
public UIElement Q1
{
get { return (UIElement)GetValue(Q1Property); }
set { SetValue(Q1Property, value); }
}
// Q2:
public static readonly DependencyProperty Q2Property =
DependencyProperty.Register("Q2", typeof(UIElement), typeof(FooCtrl), new UIPropertyMetadata(null));
public UIElement Q2
{
get { return (UIElement)GetValue(Q2Property); }
set { SetValue(Q2Property, value); }
}
// Q3:
// ....
// Q4:
// ....
public void DoSomething()
{
// ...
}
}
I use the control like:
<my:FooCtrl>
<my:FooCtrl.Q1>
<ContentControl Content="{Binding ...}" />
</my:FooCtrl.Q1>
<my:FooCtrl.Q2>
<ContentControl Content="{Binding ...}" />
</my:FooCtrl.Q2>
<my:FooCtrl.Q3>
<ContentControl Content="{Binding ...}" />
</my:FooCtrl.Q3>
<my:FooCtrl.Q4>
<ContentControl Content="{Binding ...}" />
</my:FooCtrl.Q4>
I can add 4 usercontrols to the FooCtrl Q1, Q2, Q3 and Q4 properties. Via the method "DoSomething()" on the FooCtrl I can change animate Q1, Q2, Q3 and Q4:
myFooCtrl.DoSomething();
How can I access the method from FooCtrl "DoSomething()" from inside my usercontrols (which are attached via Q1, Q2, Q3, Q4)? E.g. if I bind a usercontrol to a contentcontrol of Q1 - Q4 and the usercontrol contains a button "Do it!" how can this access the "DoSomething()" from FooCtrl so that it gets executed?
If it helps: I'm also using Caliburn.Micro.