Câu hỏi phỏng vấn Xamarin
Câu hỏi

How will you navigate from one page to another?

Câu trả lời

In Xamarin.Forms, you can navigate from one page to another using the NavigationPage and Navigation classes.

Here's an example of how you can do it:

// Create a new NavigationPage
var navigationPage = new NavigationPage(new MainPage());

// Push a new page onto the navigation stack
navigationPage.PushAsync(new DetailPage());

// Pop the current page from the navigation stack
navigationPage.PopAsync();

// Push a new page onto the navigation stack and remove the current page
navigationPage.PushAsync(new DetailPage(), true);

In your XAML file, you can use the Navigation.PushAsync method in the code-behind to navigate to another page:

private async void Button_Clicked(object sender, EventArgs e)
{
    await Navigation.PushAsync(new DetailPage());
}

You can also use the Navigation.PopAsync method to go back to the previous page:

private async void Button_Clicked(object sender, EventArgs e)
{
    await Navigation.PopAsync();
}

If you want to navigate to a page and remove the current page from the navigation stack, you can use the Navigation.PushAsync method with the true parameter:

private async void Button_Clicked(object sender, EventArgs e)
{
    await ...
junior

junior

Gợi ý câu hỏi phỏng vấn

middle

What is info.plist in Xamarin.iOS ?

middle

Explain how to use shared projects in Xamarin?

senior

How do we provide Platform specific styling or values in XAML?

Bình luận

Chưa có bình luận nào

Chưa có bình luận nào