xamarin / Xamarin.Forms

Xamarin.Forms is no longer supported. Migrate your apps to .NET MAUI.
https://aka.ms/xamarin-upgrade
Other
5.62k stars 1.87k forks source link

Current Application gets overridden, causes application level resources to disappear #1418

Open Sevenish opened 6 years ago

Sevenish commented 6 years ago

Use case forms embedding, with application level staticresources:

In this case the existing current XF application gets overridden with an empty one at https://github.com/xamarin/Xamarin.Forms/blob/4c8f901e2333ac1baae818ead61c93559f39758d/Xamarin.Forms.Platform.iOS/PageExtensions.cs#L15

Normally the RealParent would be set when assiging main page. But with embedding this is not used. The code should check wether there is a current XF application before overwriting it.

A workaround until this is fixed is setting the parent manually

var xfPage = new XfPage();
xfPage.Parent = Xamarin.Forms.Application.Current;
var naviteVC = xfPage.CreateViewController();
g-giannis commented 6 years ago

Is there any information about when this will be fixed?

samhouts commented 4 years ago

This issue doesn't seem to have had any activity in a long time. We're working on prioritizing issues and resolving them as quickly as we can. To help us get through the list, we would appreciate an update from you to let us know if this is still affecting you on the latest version of Xamarin.Forms, since it's possible that we may have resolved this as part of another related or duplicate issue. If we don't see any new activity on this issue in the next 30 days, we'll evaluate whether this issue should be closed. Thank you!

Sevenish commented 4 years ago

This issue has NOT been resolved. The work around is still required

samhouts commented 4 years ago

@Sevenish Thank you for confirming it!

mnxamdev commented 3 years ago

We're getting a crash in UWP as well which may be related. FormsPresenter_OnSizeChanged

We were informed of a NullReference exception but it wasn't clear where it was. I dug into the UAP.FormsPresenter in the SizeChanged handler but the only thing I could see there is that the crash could happen if the RealParent was null, however Visual Studio did not show any RealParent to be null on any page object I was looking at. https://github.com/xamarin/Xamarin.Forms/blob/80a4dbfb1cd897f478c38d0aafa6a5d67940d2f3/Xamarin.Forms.Platform.UAP/FormsPresenter.cs

We are doing NavigationPage.PushAsync(page, animated) and the crash started since we updated to Xamarin.Forms 5.0.0.2012. My work around is similar to the work around mentioned above in that before I call PushAsync I assign Xamarin.Forms.Application.Current to the Parent property of my Detail page.

Hackmodford commented 2 years ago

It is still an issue.