I have a button in main.xaml with a click event that is created in main.cs. I also have a method created in a user-control.cs. How do I route the click event from main.xaml to activate the method in usercontrol.cs.
Example below:
[main.cs]
public void firststudybutton(object sender, MouseButtonEventArgs e)
{
}
[user-control.cs]
public void firstButton_Click(object sender, RoutedEventArgs e)
{
studentsViewSource.View.MoveCurrentToFirst();
}
What method would I put in firststudybutton to activate method in firstButton_Click?
Loading
arjunPosted Jul 8, 2013, 2:07 AM
try like this
crate object for user-control class in main.
then create a method in usercontrol class like public void test()
in that method call click event like firstButton_Click(null,null);.
Now access this method from main using usercontrol object
like user-control userCon=new user-control();
userControl.test();
then test method executes the code what ever u wrote in button click event
i have attached sample code.please go through and revert me if it works.
thanks