在WPF中實(shí)現(xiàn)跳轉(zhuǎn)可以使用以下方法:
private void LoginButton_Click(object sender, RoutedEventArgs e)
{
frame.Navigate(new TargetPage());
}
private void LoginButton_Click(object sender, RoutedEventArgs e)
{
NavigationWindow window = new NavigationWindow();
window.Content = new TargetPage();
window.Show();
this.Close();
}
MainWindow.xaml:
<Grid x:Name="LoginGrid">
<!-- 登錄界面的內(nèi)容 -->
</Grid>
<Grid x:Name="TargetGrid" Visibility="Hidden">
<!-- 目標(biāo)界面的內(nèi)容 -->
</Grid>
MainWindow.xaml.cs:
private void LoginButton_Click(object sender, RoutedEventArgs e)
{
LoginGrid.Visibility = Visibility.Hidden;
TargetGrid.Visibility = Visibility.Visible;
}
以上是三種常見的實(shí)現(xiàn)跳轉(zhuǎn)的方式,你可以根據(jù)自己的需求選擇適合的方法。