【发布时间】:2016-07-12 14:18:18
【问题描述】:
我有一个按钮,单击时会运行一些代码。然后它更新它的文本。我希望相同的按钮在单击时导航到下一页。
现在,它会自动转到 NewPage。我怎样才能让它在点击时进入下一页?
private void Button1_Click(object sender, RoutedEventArgs e) {
// some code here
Button1.Content = "Next";
// here is the problem
NewPage np = new NewPage();
this.NavigationService.Navigate(np);
}
【问题讨论】:
-
“下一页”是什么?请包含与此问题相关的完整代码。最好的问候,
-
什么是“下一页”?
-
@AlexBell 它是 WPF 中的一个页面。
-
你试过
this.NavigationService.Navigate(typeof(NextPage);吗? -
@ganchito55 它有效。但我希望在用户再次单击按钮 (button1) 后进行导航。谢谢
标签: c# wpf xaml user-interface button