Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

New Application Class Initialization

$
0
0

We have an application that first uses Xamarin.iOS and Xamarin.Android, as well as native Windows Phone.

Using the pre 1.3.0 way of starting Xamarin Forms, we were able to initialize the Forms portion of our application and work from there.

If we try that with the new LoadApplication way of doing things, we either instantiate extra Application classes and crash or we load the instantiated Application class and the Application is crashes the second time we enter the Forms portion of our application.

Using the ConvertPageToUIElement seems to cause the same crash now.

This is the exception given trying to call the LoadApplication method a second time:

System.InvalidOperationException was unhandled by user code
HResult=-2146233079
Message=Element is already the child of another element.
Source=System.Windows
StackTrace:
at MS.Internal.XcpImports.CheckHResult(UInt32 hr)
at MS.Internal.XcpImports.Collection_AddValue[T](PresentationFrameworkCollection1 collection, CValue value)
at MS.Internal.XcpImports.Collection_AddDependencyObject[T](PresentationFrameworkCollection1 collection, DependencyObject value)
at System.Windows.PresentationFrameworkCollection1.AddDependencyObject(DependencyObject value)
at System.Windows.Controls.UIElementCollection.AddInternal(UIElement value)
at System.Windows.PresentationFrameworkCollection1.Add(T value)
at Xamarin.Forms.Platform.WinPhone.Platform.SetCurrent(Page page, Boolean animated, Boolean popping, Action completedCallback)
at Xamarin.Forms.Platform.WinPhone.Platform.SetPage(Page newRoot)
at Xamarin.Forms.Forms.ConvertPageToUIElementWithoutApp(Page page, PhoneApplicationPage applicationPage)
at Xamarin.Forms.Platform.WinPhone.FormsApplicationPage.SetMainPage()
at Xamarin.Forms.Platform.WinPhone.FormsApplicationPage.LoadApplication(Application application)
at ourAppNamespace.WinPhone.Pages.FormsPage..ctor()
at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)

So I guess my question is, how do you do native to forms using the new application class?

I have included a sample project with the same general concept as our application. I did not set up the iOS project as my issue is with the Windows Phone project. The Android project is setup to demonstrate what I think is the correct performance.


Viewing all articles
Browse latest Browse all 58056

Trending Articles