How to close multiple contentpages in Xamarin - c#

I developed two ContentPages to let user choose Country and City.
My application starts with Navigation Page:
MainPage = new NavigationPage(new Views.InfoViews.OnBoarding());
OnBoarding page redirects Country selection page and country selection page redirects city selection page like below:
Navigation.PushAsync(new LocationSelector(0));
I want to return onboarding page after place selection.
How can i do that?

to return to the first page in your navigation stack
Navigation.PopToRootAsync();

Related

Show new Page from a button in a Detail Page

I have a MasterDetailPage. I can add a page from my "Menu" and it is content inside the master page. When I want to do the same but with a button from my "FirstMasterPage" it show the Page but over the MasterDetailPage
I tried to create a new MasterPage but not showing nothing
This is the action of the button of one of my pages
Navigation.PushModalAsync(new Pagina_Dos());
I also tried this, but showing nothing. Pagina_Master is my MasterDetailPage
MasterDetailPage mdp = new Pagina_Master();
mdp.Detail.Navigation.PushModalAsync(new Pagina_Dos());
mdp.IsPresented = false;
I want to show my content Page (Pagina_Dos) inside my Master Detail Page, when is clicked from the button. Because from the menu of course its working
first you need a reference to the current MasterDetailPage
var mdp = (MasterDetailPage)App.Current.MainPage;
then you can use the Detail's Navigation property to push a new page
mdp.Detail.Navigation.PushAsync(new Pagina_Dos());

How to navigate pages without navigation stack in master detail page?

I've created a PCL project where I'm having a main page where the person can navigate to three sections and each seciton has a login page. After logging in the master detail page comes which has number of pages to navigate.
Navigation Page
Main Page (can be popped)
Login (can be popped)
Master Page
Detail Page
Navigation Page
SubPages
When I'm navigating to detail pages, then it shows the error that android can't have two navigation stacks. How should I navigate to master page without navigation page or what should I do?
You can directly set the MainPage of the App class when you are showing your main page or login page, and wrap your detail page in NavigationPage.
//show main page
MainPage = new MyMainPage();
//show login page
MainPage = new LoginPage ();
//show master detail
MainPage = new MyMasterDetailPage
{
MasterPage = new MyMasterPage()
DetailPage = new NavigationPage(MyDetailPage)
}

How to Navigate from Tab Page to Normal WPF Page

I have four tab pages in Tab controller. I wish to navigate from a tab page to Normal WPF page. For that I am using this.NavigationService.Navigate(new Page1()); . I am able to navigate to new page that is Page1 but the tab control is still there. Seems Like only stack panel is getting replaced. Is there any way to do it correctly?
You are calling the Navigate method on the ListBox, so only that control is replaced. By setting the MainWindow's Content, only the new Page will be displayed:
Application.Current.MainWindow.Content = new Page1();

Multiple update Panel in Form

I am new Asp.net and working on project, where I have to ajaxify the basic asp.net
I have master page and content page. Master page has menu and buttons. The content page have various fieldsets as below.
Update Record Fieldset
Add Record Fieldset
Query and Grid.
updatepanel id=UpdatePanelOuter runat=server UpdateMode=Conditional> Likewise for all the nested UpdatePanels. The Scriptmanager is in Masterpage with EnablePartialRendering=true
What I have in code behind is ScriptManager1.RegisterAsyncPostBackControl(AddUpdatePanel) In button click event function AddUpdatePanel.Update() .
When the content page is loaded, I have the queryform and DataGrid. There are couple grid command like view, update and delete.
When I click update command from the grid, I am making UpdateFieldset.visible=true and QueryGridField.visible=false.
On submit button, its stored the data , give the message and go back to original contentpage with querygridFieldset.visible =true.
Question: What I am trying and have not been successfull is
when I click on the buttons, my datetime , menus in the master page
must not be refreshed.
On click in the Update button, only that particular Fieldset should
be sent to the server.
At the same time, I have updated by Web.config and there is no compilation error
Master Page: Menu, Current System Date time, Login Name, Buttons
Content Page: ContentPlaceHolder1 UpdateRecordFieldset AddRecordFieldset QueryandGridFieldset
Not sure what excalty is your requirement but if you have multiple update panels and master page and content page structure.
Please check the script manager and update panel properties according to this link:
http://www.asp.net/ajax/documentation/live/overview/updatepaneloverview.aspx
"Using UpdatePanel Controls in Master Pages" & "Using Nested UpdatePanel Controls" are titles in same link.
Hope this help.

Windows Phone Silverlight page navigation

I have two questions here about Windows Phone page navigation:
Is there a way to get the instance of the page I am navigating to? That is, if I am on page one and want to navigate to page2 to when button click, can I get the page2 instance after page2 is initialized by NavigationService.Navigate("page_2_uri") call in page 1?
Is there a way I can know which page I navigate from? For example, I am currently on page3, and I want to do something like: if page 3 is navigated from page 2, I will do this, otherwise I will do that.
Thank you.
Is there a way to get the instance of the page I am navigating to?
No.
Is there a way I can know which page I navigate from?
Yes. Traverse the NavigationService.BackStack
The idea for using the NavigationService to navigate between pages is that you don't need to know any details about your destination. So in your example, Page 2 isn't initialized until you've left Page 1, and therefore Page 1 is no longer in scope, and won't be able to do anything with Page 2. If you want to pass information/context to Page 2, id recommend using Query Parameters (see next answer). If you want to know where the navigation is going, you can override the OnNavigatedFrom event and look at the Uri property of the NavigationEventArgs.
I would recommend looking at the NavigationContext property of the Silverlight Page class. This property lets you view the QueryString of the navigation request. Using this approach, you could navigate to page 3 using a uri like "page_3?previous_page=2" and then extract the previous_page from the QueryString of the NavigationContext to see where you came from.

Categories

Resources