Reputation:
Before downvote: let me remind that there is no method "btnDoSomething.Click();"
xaml contents:
<AppBarButton x:Name="btnDoSomething" Icon="Accept"/>
I want to click it from "OnNavigatedTo" method. How to do this?
Upvotes: 0
Views: 57
Reputation: 3998
There is no reason to click a button on the OnNavigatedTo!?. When you click a button you wanna ToDO and Code. Do that ToDO and Code in your OnNavigatedTo.
But If you wanna click it just call the method btnDoSomething_Click(sender, args);
Upvotes: 0
Reputation: 45361
Don't click a button from code in order to do the same action in a different event.
Let btnDoSomething
execute the same method on click which you can call in OnNavigatedTo
.
private void appBarButton_Click(object sender, RoutedEventArgs e)
{
DoStuff();
}
protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
DoStuff();
}
private void DoStuff()
{
//...
}
Upvotes: 1