Create two user controls ControlA and ControlB add these controls in MainPage
Add a button in ControlA and Add some textboxes in ControlB
Here is the Class A code
public partial class ControlA : UserControl
{
public ControlA()
{
InitializeComponent();
}
private void btnDelegate_Click(object sender, RoutedEventArgs e)
{
if (this._RaiseDelegateInvokerEvent !=null)
{
this._RaiseDelegateInvokerEvent(this, new BindingEventArgs { Fname = "Chaitanya", Lname = "SVS", Designation = "Always Developer" });
}
}
public delegate void DelegateInvoker(object sender, BindingEventArgs e);
public event DelegateInvoker _RaiseDelegateInvokerEvent;
}
And here is the MainPage Code
public partial class MainPage : UserControl
{
public MainPage()
{
InitializeComponent();
//CntrlA._RaiseDelegateInvokerEvent += new ChildControls.ControlA.DelegateInvoker(CntrlA__RaiseDelegateInvokerEvent);
}
void CntrlA__RaiseDelegateInvokerEvent(object sender, BindingEventArgs e)
{
CntrlB.LayoutRoot.DataContext = e;
}
}
Add a button in ControlA and Add some textboxes in ControlB
Here is the Class A code
public partial class ControlA : UserControl
{
public ControlA()
{
InitializeComponent();
}
private void btnDelegate_Click(object sender, RoutedEventArgs e)
{
if (this._RaiseDelegateInvokerEvent !=null)
{
this._RaiseDelegateInvokerEvent(this, new BindingEventArgs { Fname = "Chaitanya", Lname = "SVS", Designation = "Always Developer" });
}
}
public delegate void DelegateInvoker(object sender, BindingEventArgs e);
public event DelegateInvoker _RaiseDelegateInvokerEvent;
}
And here is the MainPage Code
public partial class MainPage : UserControl
{
public MainPage()
{
InitializeComponent();
//CntrlA._RaiseDelegateInvokerEvent += new ChildControls.ControlA.DelegateInvoker(CntrlA__RaiseDelegateInvokerEvent);
}
void CntrlA__RaiseDelegateInvokerEvent(object sender, BindingEventArgs e)
{
CntrlB.LayoutRoot.DataContext = e;
}
}