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:

csharp Copy
// 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:

csharp Copy
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:

csharp Copy
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:

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

junior

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

middle

Explain how to use shared projects in Xamarin?

senior

What are the disadvantages of Xamarin for Android development?

junior

What is is the difference between ListView & TableView ?

Bình luận

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

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