在WPF中實現跳轉可以使用以下方法:
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">
<!-- 登錄界面的內容 -->
</Grid>
<Grid x:Name="TargetGrid" Visibility="Hidden">
<!-- 目標界面的內容 -->
</Grid>
MainWindow.xaml.cs:
private void LoginButton_Click(object sender, RoutedEventArgs e)
{
LoginGrid.Visibility = Visibility.Hidden;
TargetGrid.Visibility = Visibility.Visible;
}
以上是三種常見的實現跳轉的方式,你可以根據自己的需求選擇適合的方法。