2
Vote

Sample app for WP throws Exception on every startup

description

System.Exception, WinRT information: Element is already child of another element.

I cannot find any more information in the exception, so it's difficult to guess why it occurs. I guess there is some C# code somewhere in startup that puts a control into an element that has already been defined in XAML, but that's just a wild guess.

I will fix it and send a pull request, if I find what causes the exception. If someone has got a clue about this, a comment would be appreciated.

comments

eloekset wrote Jul 24, 2015 at 5:56 PM

Something in AppShell is causing the exception, but I don't know exactly what it is.

I commented out the AppShell code in OnLaunched() and replaced it with standard code using a Frame. Also the SampleButtonViewModel must be changed to ((Frame)Window.Current.Content).Navigate() instead of AppShell.Frame.Navigate(). Then the sample app runs fine, but backnavigation closes the app instead of navigating back to MainPage.

xyzzer wrote Jul 24, 2015 at 6:01 PM

Thanks for reporting this.

Could you share more details about
  • Which version of the toolkit you're using - is it the latest from git?
  • Which version of the phone OS
  • Which phone or is it emulator?
  • Does it repro in the PC sample as well?
In general you'd see that exception if you have an element in the visual tree and also try to add it elsewhere in the visual tree.

eloekset wrote Jul 24, 2015 at 9:37 PM

  • I'm using the latest from Git (master branch as of commit 969b48353684, Jan 30, 2015)
  • I'm using version 8.10.12358.1191 of the OS
  • It's the WP 8.1 emulator
  • Windows Store (PC) sample doesn't have this problem