Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
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
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.
Created attachment 10147 [details]
The attached sample will throw an exception when run on a Windows Phone. A ScrollView is added to a ContentView and set as the Content of a page.
**Steps to Reproduce:**
1. Run the attached sample on Windows Phone (The ScrollViewIssue.WinPhone project)
2. Touch the View B button
3. Touch the View A button
4. Touch the View B button again
An Argument not in range exception occurs.
**Build Date & Platform:**
Works on Android.
Created attachment 10307 [details]
Zip Xamarin Log
I have checked this issue with attached sample app and able to reproduce it. I observed that when I press the "View B" button then press "View A" button again press "View B" button, I observed that 'System.ArgumentException' has been thrown.
Please let me know if I can provide any other info/log.
I have checked this issue with xamarin forms version 1.4.0.
Microsoft Visual Studio Professional 2013
Version 12.0.30723.00 Update 3
Microsoft .NET Framework
Installed Version: Professional
Xamarin 3.9.517.0 (856798e)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.
Xamarin.Android 126.96.36.199 (9e05e39f02bafe8fc0b7ab025d99f3b446835ad4)
Visual Studio plugin to enable development for Xamarin.Android.
Xamarin.iOS 188.8.131.52 (61fa2c6e0f2ef51eb98b8810de13b4469f379cc7)
Visual Studio extension to enable development for Xamarin.iOS.
Xamarin.iOS Unified Migration 1.0
Automated migration for Xamarin iOS Classic projects to Unified
I have the same issue with XF.
When I reassign a view that contains a ScrollView, I get an exception on Android:
Java.Lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
Created attachment 10561 [details]
Sample Reproduce Scroll View Bug
I created an app for Android and WP, that demos the bug in a few lines.
Description in the startscreen of the app.
The Android test case from comment 3 does indeed fail on Xamarin.Forms 184.108.40.20696, but it does _not_ fail on more recent versions (tested on Xamarin.Forms 220.127.116.1149).
The Windows Phone test case from comment 3 does still fail as of Xamarin.Forms 18.104.22.16849, and the top of the stack trace is the same as in the original test case from comment 0.
## Notes about the test case from comment 0
- It looks like the StackLayout within the ScrollView becomes "stale" after the first time it's used to set `System.Windows.Controls.ContentControl.Content` (in `ScrollViewRenderer.LoadContent()`).
- The second time `ScrollViewRenderer.LoadContent()` tries to set `System.Windows.Controls.ContentControl.Content` to the StackLayout, it fails.
- It's possible to hack around the problem re-creating the StackLayout and re-adding it to viewB's ScrollView each time the "View B" button is tapped.
## Related bug
Bug 26233 looks like it might be closely related, but that bug does not currently include a test case.
## Top of the exception message + stack trace from the test case in comment 0.
> System.ArgumentException was unhandled by user code
> Message=Value does not fall within the expected range.
> at MS.Internal.XcpImports.CheckHResult(UInt32 hr)
> at MS.Internal.XcpImports.SetValue(IManagedPeerBase obj, DependencyProperty property, DependencyObject doh)
> at MS.Internal.XcpImports.SetValue(IManagedPeerBase doh, DependencyProperty property, Object obj)
> at System.Windows.DependencyObject.SetObjectValueToCore(DependencyProperty dp, Object value)
> at System.Windows.DependencyObject.SetEffectiveValue(DependencyProperty property, EffectiveValueEntry& newEntry, Object newValue)
> at System.Windows.DependencyObject.UpdateEffectiveValue(DependencyProperty property, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, ValueOperation operation)
> at System.Windows.DependencyObject.SetValueInternal(DependencyProperty dp, Object value, Boolean allowReadOnlySet)
> at System.Windows.Controls.ContentControl.set_Content(Object value)
> at Xamarin.Forms.Platform.WinPhone.ScrollViewRenderer.LoadContent()
> at Xamarin.Forms.Platform.WinPhone.ScrollViewRenderer.OnElementChanged(ElementChangedEventArgs`1 e)
Should be fixed in 1.5.1-pre1
I have checked this issue with Xamarin.Forms 1.5.1-pre1 and its working fine.
Hence closing this issue.