如何在我的代码中直接触发按钮单击?
我有这样的代码:
namespace App1
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
}
protected override void OnNavigatedTo(NavigationEventArgs e)
{
// fire a click ebent von the "Button" MyBtn
}
private void Button_Click(object sender, RoutedEventArgs e)
{
// ...
}
}
}
是否可以触发按钮的点击事件MyBtn
?如果是怎么办?
我知道我可以调用该Button_Click
方法,但我想通过按钮调用它。
就像是:MyBtn.FireClickEvent();