Bug 31124 - change MasterDetail.Detail navigation page
Summary: change MasterDetail.Detail navigation page
Status: RESOLVED ANSWERED
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 1.4.2
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2015-06-15 14:39 UTC by Alessandro
Modified: 2015-06-17 13:09 UTC (History)
4 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
project with bug (183.07 KB, application/zip)
2015-06-15 14:39 UTC, Alessandro
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED ANSWERED

Description Alessandro 2015-06-15 14:39:09 UTC
Created attachment 11608 [details]
project with bug

I have a masterdetail.
The Detail in a navigationPage.
In Android (iOS no problem), if I change the Detail with Detail = new NavigationPage(new PageDetail1()); it WORKS.
If I change with Detail = App.NP (a static NavigationPage) it does not work.
I don't know if it's a bug or it a mine mistake. I know that in iOS I have no exception.

To recreate:
1- run the project
2- visualize the master
3- click first button

this is the exception
The specified child already has a parent. You must call removeView() on the child's parent first.

The solution could be remove all pages from Detail, but I don't know how...
And in iOS I have't this problem..
Let me know
Thanks
Comment 1 Rui Marinho 2015-06-17 06:06:00 UTC
Hi you shouldn't keep static reference to pages in your App that are being re-added to the navigation stack.
Looking at your code here's a suggest fix that would make your current implementation work:

	public static void SetMainNavigationPage(Page page){

			NavigationPage np;
			if (page.Parent != null)
				np = page.Parent as NavigationPage;
			else
				np = new NavigationPage (page);

			App.NP = np; //{BarBackgroundColor = Library.ColorXamarin, BarTextColor = Color.White};
			App.NP.BarBackgroundColor = ColorXamarin;
			App.NP.BarTextColor = Color.White;
			App.NP.Icon = "transparent";
		}
Comment 2 Alessandro 2015-06-17 13:09:54 UTC
thanks Rui
it works