Prism Xamarin Navigation - strange behaviour - xamarin.forms

I have a MasterDetail page which in Xaml has defined a navigation menu as a master bit and just an empty Detail.
Once user logs in I navigate to the main page using the following path
await _navigationService.NavigateAsync(PageCodes.NavigateTo_MainMenuPage + "/" + PageCodes.NavigateTo_NavigationPage + "/" + PageCodes.NavigateTo_WelcomePage);
NavigateTo_MainMenuPage is my MasterDetail Page
NavigateTo_NavigationPage an empty Navigation page
NavigateTo_WelcomePage my home page (content page)
This works perfectly, iOS shows both Navigation (master) and Welcome page (content page)
One of the options in the navigation is to go to About page (so user triggers this via MasterDetail.Master XAML)
I expected that this code
await _navigationService.NavigateAsync(PageCodes.NavigateTo_WebPage, param);
will replace the Detail bit of the MasterDetail Page but instead of that it opens it as a model page (full screen) and app loses the Hamburger menu. I even tried to add false, after param but it didn't work
This code
await _navigationService.NavigateAsync(PageCodes.NavigateTo_NavigationPage + "/" + PageCodes.NavigateTo_WebPage, param, false);
opens the page as a child of the main page (iOS shows back to welcome page) which I don't want.
I even tried this code
await _navigationService.NavigateAsync(PageCodes.NavigateTo_MainMenuPage + "/" + PageCodes.NavigateTo_NavigationPage + "/" + PageCodes.NavigateTo_WebPage, param, false);
but it shows NavigateTo_WebPage without Master page and as I can see the hamburger menu is missing
Just to clarify all this code is happening in the view of MainMenuPage (MainMenuPageViewModel)
So My question is what I'm doing wrong and how to push with Prism new content to Detail bit of MasterDetail page
thanks in advance!!!

I've managed to fix the problem. My Navigation page didn't have a ViewModel. Frankly, I thought as it's a dummy page without any logic I don't need the ViewModel.
As soon as I added the page, everything was fine

Related

After navigating to another page hybridWebView does not register any actions

I use project hybridWebView standart. Xamarin.Forms - HybridWebView Custom Renderer
If i use the html file that is in the Android project - Content / index.html - Everything works.
If I use html file which is hosted by mysite.com - The first time the hybridWebViewPage.axml page is loaded, I get the data in a variable var data. If I go to another page, and then go back to the hybridWebViewPage.axml page, I do not get data in the variable var data.
hybridWebView.RegisterAction(data => DisplayAlert("Alert", "Hello " + data, "OK"));
Why is this happening?
Because the hybridWebView.RegisterAction method is called in the construction method of the contentpage which will be called when you navigate to it first time. In addition, when you come back from another page, the construction method will not be called because the instance of it is still in the storge. There is the link about the navigation stack.link

My problem is about wechat pages jump ,when i want jump to one page ,it always flash another pages

pages order is shelf->photo->refer->photos->shelf.but when photos->shelf,the refer page always flash.
wx.navigateTo({
url: '../shelf?rstoreId=' + this.data.rstoreId,
})
Be sure that there are 'shelf.wxml','shelf.wxss' and 'shelf.js' in your 'shelf' folder.
Use '../shelf/shelf' instead of '../shelf'
wx.navigateTo({
url: '../shelf/shelf?rstoreId=' + this.data.rstoreId,
})

Xamarin Forms, error in the Master Details

When I return to the Root Page with this method:
Page page = (Page)Activator.CreateInstance(typeof(TrasfMagaPage), session);
Navigation.InsertPageBefore(page, Navigation.NavigationStack[0]);
await Navigation.PopToRootAsync(true);
The icon of the hamburger menu disappears from the TopBar.
I use the same code with all the other pages, but only in this case it presents the problem.
How is that possible?
I have written code similar to this to prevent a white flicker that appears in Android master detail pages. When inserting a page before the root, I use the Navigation of the Detail page.
Detail.Navigation.InsertPageBefore(page, root);
await Detail.Navigation.PopToRootAsync(false);

How to navigate back from FreshMasterDetailNavigationContainer with FreshMvvm?

I use the following code to start a freshhmvvm master-detail page from a list in a navigation page. This works fine, but the user can not go back to the list page on IOS. On android it is possible using the system back-button from each detailpage.
Does this mean I have to add a 'Back' button to each detailpage to make this work on IOS?
Or are there other ways to start a masterdetail in freshmvvm?
var masterDetailNav = new FreshMasterDetailNavigationContainer();
masterDetailNav.Init("Menu");
masterDetailNav.AddPage<FirstPageModel>("First", item);
masterDetailNav.AddPage<SecondPageModel>("Second", item.id);
await CoreMethods.PushNewNavigationServiceModal(masterDetailNav);

Xamarin Forms - Getting Rid of Back Button In Nav Bar

Lets say the first page in the app is the login page and then it takes me to do the main menu screen, is there a way to get rid of the back button in the main menu navigation bar, like get rid of the login page stack?
thank you
In Xamarin.Forms 1.3 and greater you can use
NavigationPage.SetHasBackButton(this, false);
In Xaml you can add:
<ContentPage ....NameSpaces etc....
NavigationPage.HasBackButton="False"
Title="MyPage">
</ContentPage>
You can avoid having the Back button if you replace the Navigation.PushAsync(page) to Navigation.PushModalAsync(page) in your login page's code. Post some code if this somehow doesn't apply
This has to do with how navigation works in the underlying OS (at least in iOS that's the case) - there is a Navigation Controller which serves for pages to transition between each other and have a trace of previous screen so the user can go back.
There are 2 ways to get rid of back button:
1) You can remove navigation bar from Xaml using Xamarin.Forms using below code
NavigationPage.SetHasNavigationBar (this, false);
Where this stands for current page / form instance.
2) Follow below mentioned steps
Navigate to login page when the app is loaded with Normal ContentPage instance of Login Page
Navigate to Main page from Login page using PushModalAsync and provide the main page instance as NavigationPage
And then from all the other pages, you can use PushAsync and it'll let you navigate to all the pages without any error.
Hope this helps!
By using CustomRenderer, you call this function in ViewWillAppear in your customized view controller
public override void ViewWillAppear (bool animated)
{
base.ViewWillAppear (animated);
this.ParentViewController.NavigationItem.SetHidesBackButton (true, false);
//remember to use ParentViewController to reference to the NavigationViewController (if your contentPage is direct under a navigation controller. I don't know why but Xamarin must have a bug with SetHidesBackButton. If you call with this.NavigationItem.SetHidesBackButton(...), it should not work.
... other implements here ...
}

Resources