Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UWP - Element is already the child of another element. #1

Open
spaddlewit opened this issue Jul 1, 2017 · 2 comments
Open

UWP - Element is already the child of another element. #1

spaddlewit opened this issue Jul 1, 2017 · 2 comments

Comments

@spaddlewit
Copy link

I created a repro project, based on your existing Mapsui.Forms.Samples PCL project, just drop it in as a replacement:
http://www.spaddlewit.com/UWPError.zip

The issue is when you Navigation.PushAsync or Navigation.PushModalAsync another form on top, and then pop back to the forms with the Mapsui control:

"System.Runtime.InteropServices.COMException: No installed components were detected.\r\n\r\nElement is already the child of another element.\r\n at System.Runtime.InteropServices.WindowsRuntime.IVector`1.Append(T value)\r\n at System.Runtime.InteropServices.WindowsRuntime.VectorToCollectionAdapter.Add[T](T item)\r\n at Mapsui.UI.Uwp.MapControl.InitAnimation()\r\n at Mapsui.UI.Uwp.MapControl.MapControlLoaded(Object sender, RoutedEventArgs e)"

Any idea what's going on here?

@spaddlewit
Copy link
Author

Here's the fix, in Mapsui.UI.Uwp.MapControl.InitAnimation():

Check if the children collection already contains '_zoomAnimation' before adding it.

        if (!_zoomStoryBoard.Children.Contains(_zoomAnimation))
            _zoomStoryBoard.Children.Add(_zoomAnimation);

@spaddlewit
Copy link
Author

This might also not be the completely 'correct' fix... should MapControlLoaded be allowed to potentially fire multiple times? Or should the event be removed inside of the MapControlLoaded event callback?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant