Open npostma opened 2 years ago
Could you attach a small sample where reproduce the issue?. Thanks in advance.
I will extract the the code to an empty project and see if i can recreate this issue this week. tbc.
@jsuarezruiz I've created a working 'crash' demo.
https://github.com/npostma/bug_reports-CarouselViewAndroidCrash
[edit] Updated to the latest nuget Xamarin forms and essentials package but the problem still exists.
Clearing the collection ( .Clear() ) in the example instead of re initializing results in the same crash.
I believe I solved your problem. Put this in your carousel viewmodel:
public void OnDisappearing() { IsBusy = false; }
then put this in your caurselpage.xaml.cs
protected override void OnDisappearing() { base.OnDisappearing();
viewModel.OnDisappearing();
ClearCarousel(); }
This should work I tested it.
What trickery is this :-) It seems to work. How can the IsBusy bool have effect on the collection?
@jsuarezruiz Is there a better way to handle this exception than the solution that @brettnguyen suggested? ( thanks for the suggestion @brettnguyen )
Hello,
This is two Stacktraces that can help to debug the crash.
To reproduce the crash :
It seems that CarouselView doesn't like having its data refreshed when not displayed.
I created an Android CarouselViewRenderer and I catched the first exception in OnElementPropertyChanged
method (the changed property is Position
) :
System.IndexOutOfRangeException: Can't set CarouselView to position -1. ItemsSource has 3 items.
at Xamarin.Forms.Platform.Android.CarouselViewRenderer.UpdateFromPosition () [0x0005d] in D:\a\1\s\Xamarin.Forms.Platform.Android\CollectionView\CarouselViewRenderer.cs:539
at Xamarin.Forms.Platform.Android.CarouselViewRenderer.OnElementPropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs changedProperty) [0x00065] in D:\a\1\s\Xamarin.Forms.Platform.Android\CollectionView\CarouselViewRenderer.cs:169
at eStay.Mobile.Droid.Components.DebugCarouselViewRenderer.OnElementPropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs changedProperty) [0x00046] in C:\Sources\EstayMobile\eStay.Mobile2\eStay.Mobile2.Android\Components\DebugCarouselViewRenderer.cs:50
After exiting the try/catch, another exception, that I didn't achieve to catch, crash the app :
**System.ArgumentOutOfRangeException:** 'Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index'
at System.Collections.Generic.List`1[T].get_Item (System.Int32 index) [0x00009] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/Common/src/CoreLib/System/Collections/Generic/List.cs:161
at System.Collections.Generic.List`1[T].System.Collections.IList.get_Item (System.Int32 index) [0x00000] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/Common/src/CoreLib/System/Collections/Generic/List.cs:188
at Xamarin.Forms.Platform.Android.ObservableItemsSource.ElementAt (System.Int32 index) [0x0000f] in D:\a\1\s\Xamarin.Forms.Platform.Android\CollectionView\ObservableItemsSource.cs:226
at Xamarin.Forms.Platform.Android.ObservableItemsSource.GetItem (System.Int32 position) [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.Android\CollectionView\ObservableItemsSource.cs:62
at Xamarin.Forms.Platform.Android.CarouselViewRenderer.SetCurrentItem (System.Int32 carouselPosition) [0x00043] in D:\a\1\s\Xamarin.Forms.Platform.Android\CollectionView\CarouselViewRenderer.cs:504
at Xamarin.Forms.Platform.Android.CarouselViewRenderer.UpdateInitialPosition () [0x00076] in D:\a\1\s\Xamarin.Forms.Platform.Android\CollectionView\CarouselViewRenderer.cs:362
at Xamarin.Forms.Platform.Android.CarouselViewRenderer.UpdateAdapter () [0x00069] in D:\a\1\s\Xamarin.Forms.Platform.Android\CollectionView\CarouselViewRenderer.cs:141
at Xamarin.Forms.Platform.Android.CarouselViewRenderer.UpdateItemsSource () [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.Android\CollectionView\CarouselViewRenderer.cs:151
at Xamarin.Forms.Platform.Android.ItemsViewRenderer`3[TItemsView,TAdapter,TItemsViewSource].SetUpNewElement (TItemsView newElement) [0x00053] in D:\a\1\s\Xamarin.Forms.Platform.Android\CollectionView\ItemsViewRenderer.cs:316
at Xamarin.Forms.Platform.Android.CarouselViewRenderer.SetUpNewElement (Xamarin.Forms.ItemsView newElement) [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.Android\CollectionView\CarouselViewRenderer.cs:94
at Xamarin.Forms.Platform.Android.ItemsViewRenderer`3[TItemsView,TAdapter,TItemsViewSource].Xamarin.Forms.Platform.Android.IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x0004f] in D:\a\1\s\Xamarin.Forms.Platform.Android\CollectionView\ItemsViewRenderer.cs:104
at void android.os.Handler.handleCallback(android.os.Messa05-09 14:34:58.122 F/stay_app.mobil(18823): java_vm_ext.cc:578] at Xamarin.Forms.Platform.Android.Platform.CreateRenderer (Xamarin.Forms.VisualElement element, Android.Content.Context context) [0x0003e] in D:\a\1\s\Xamarin.Forms.Platform.Android\Platform.cs:358
at Xamarin.Forms.Platform.Android.VisualElementPackager.AddChild (Xamarin.Forms.VisualElement view, Xamarin.Forms.Platform.Android.IVisualElementRenderer oldRenderer, Xamarin.Forms.Platform.Android.RendererPool pool, System.Boolean sameChildren) [0x000b3] in D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementPackager.cs:140
at Xamarin.Forms.Platform.Android.VisualElementPackager.Load () [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementPackager.cs:112
at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].SetPackager (Xamarin.Forms.Platform.Android.VisualElementPackager packager) [0x00007] in D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:481
at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].SetElement (TElement element) [0x000e8] in D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:244
at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].Xamarin.Forms.Platform.Android.IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x00033] in D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:131
at Xamarin.Forms.Platform.Android.Platform.CreateRenderer (Xamarin.Forms.VisualElement element, Android.Content.Context context) [0x0003e] in D:\a\1\s\Xamarin.Forms.Platform.Android\Platform.cs:358
at Xamarin.Forms.Platform.Android.VisualElementPackager.AddChild (Xamarin.Forms.VisualElement view, Xamarin.Forms.Platform.Android.IVisualElementRenderer oldRenderer, Xamarin.Forms.Platform.Android.RendererPool pool, System.Boolean sameChildren) [0x000b3] in D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementPackager.cs:140
at Xamarin.Forms.Platform.Android.VisualElementPackager.SetElement (Xamarin.Forms.VisualElement oldElement, Xamarin.Forms.VisualElement newElement) [0x00163] in D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementPackager.cs:351
at Xamarin.Forms.Platform.Android.VisualElementPackager.Load () [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementPackager.cs:112
at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].SetPackager (Xamarin.Forms.Platform.Android.VisualElementPackager packager) [0x00007] in D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:481
at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].SetElement (TElement element) [0x000e8] in D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:244
at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].Xamarin.Forms.Platform.Android.IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x00033] in D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:131
at Xamarin.Forms.Platform.Android.Platform.CreateRenderer (Xamarin.Forms.VisualElement element, Android.Content.Context context) [0x0003e] in D:\a\1\s\Xamarin.Forms.Platform.Android\Platform.cs:358
at Xamarin.Forms.Platform.Android.ScrollViewContainer.set_ChildView (Xamarin.Forms.View value) [0x0002f] in D:\a\1\s\Xamarin.Forms.Platform.Android\Renderers\ScrollViewContainer.cs:35
at Xamarin.Forms.Platform.Android.ScrollViewRenderer.LoadContent () [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.Android\Renderers\ScrollViewRenderer.cs:369
at Xamarin.Forms.Platform.Android.ScrollViewRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x000cf] in D:\a\1\s\Xamarin.Forms.Platform.Android\Renderers\ScrollViewRenderer.cs:99
at Xamarin.Forms.Platform.Android.Platform.CreateRenderer (Xamarin.Forms.VisualElement element, Android.Content.Context context) [0x0003e] in D:\a\1\s\Xamarin.Forms.Platform.Android\Platform.cs:358
at Xamarin.Forms.Platform.Android.VisualElementPackager.AddChild (Xamarin.Forms.VisualElement view, Xamarin.Forms.Platform.Android.IVisualElementRenderer oldRenderer, Xamarin.Forms.Platform.Android.RendererPool pool, System.Boolean sameChildren) [0x000b3] in D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementPackager.cs:140
at Xamarin.Forms.Platform.Android.VisualElementPackager.SetElement (Xamarin.Forms.VisualElement oldElement, Xamarin.Forms.VisualElement newElement) [0x00163] in D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementPackager.cs:351
at Xamarin.Forms.Platform.Android.VisualElementPackager.Load () [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementPackager.cs:112
at Xamarin.Forms.Platform.Android.VisualElementPackager.AddChild (Xamarin.Forms.VisualElement view, Xamarin.Forms.Platform.Android.IVisualElementRenderer oldRenderer, Xamarin.Forms.Platform.Android.RendererPool pool, System.Boolean sameChildren) [0x00041] in D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementPackager.cs:125
at Xamarin.Forms.Platform.Android.VisualElementPackager.SetElement (Xamarin.Forms.VisualElement oldElement, Xamarin.Forms.VisualElement newElement) [0x00163] in D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementPackager.cs:351
at Xamarin.Forms.Platform.Android.VisualElementPackager.Load () [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementPackager.cs:112
at Xamarin.Forms.Platform.Android.VisualElementPackager.AddChild (Xamarin.Forms.VisualElement view, Xamarin.Forms.Platform.Android.IVisualElementRenderer oldRenderer, Xamarin.Forms.Platform.Android.RendererPool pool, System.Boolean sameChildren) [0x00041] in D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementPackager.cs:125
at Xamarin.Forms.Platform.Android.VisualElementPackager.SetElement (Xamarin.Forms.VisualElement oldElement, Xamarin.Forms.VisualElement newElement) [0x00163] in D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementPackager.cs:351
at Xamarin.Forms.Platform.Android.VisualElementPackager.Load () [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementPackager.cs:112
at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].SetPackager (Xamarin.Forms.Platform.Android.VisualElementPackager packager) [0x00007] in D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:481
at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].SetElement (TElement element) [0x000e8] in D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:244
at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].Xamarin.Forms.Platform.Android.IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x00033] in D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:131
at Xamarin.Forms.Platform.Android.Platform.CreateRenderer (Xamarin.Forms.VisualElement element, AndroidX.Fragment.App.FragmentManager fragmentManager, Android.Content.Context context) [0x00031] in D:\a\1\s\Xamarin.Forms.Platform.Android\Platform.cs:404
at Xamarin.Forms.Platform.Android.AppCompat.FragmentContainer.OnCreateView (Android.Views.LayoutInflater inflater, Android.Views.ViewGroup container, Android.OS.Bundle savedInstanceState) [0x00008] in D:\a\1\s\Xamarin.Forms.Platform.Android\AppCompat\FragmentContainer.cs:57
at AndroidX.Fragment.App.Fragment.n_OnCreateView_Landroid_view_LayoutInflater_Landroid_view_ViewGroup_Landroid_os_Bundle_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_inflater, System.IntPtr native_container, System.IntPtr native_savedInstanceState) [0x00021] in D:\a\1\s\generated\androidx.fragment.fragment\obj\Release\monoandroid9.0\generated\src\AndroidX.Fragment.App.Fragment.cs:1977
at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.68(intptr,intptr,intptr,intptr,intptr)
at android.view.View crc64720bb2db43a66fe9.FragmentContainer.n_onCreateView(android.view.LayoutInflater, android.view.ViewGroup, android.os.Bundle) (FragmentContainer.java:-2)
at android.view.View crc64720bb2db43a66fe9.FragmentContainer.onCreateView(android.view.LayoutInflater, android.view.ViewGroup, android.os.Bundle) (FragmentContainer.java:41)
at void androidx.fragment.app.Fragment.performCreateView(android.view.LayoutInflater, android.view.ViewGroup, android.os.Bundle) (Fragment.java:2963)
at void androidx.fragment.app.FragmentStateManager.createView() (FragmentStateManager.java:518)
at void androidx.fragment.app.FragmentStateManager.moveToExpectedState() (FragmentStateManager.java:282)
at void androidx.fragment.app.FragmentManager.executeOpsTogether(java.util.ArrayList, java.util.ArrayList, int, int) (FragmentManager.java:2189)
at void androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(java.util.ArrayList, java.util.ArrayList) (FragmentManager.java:2100)
at void androidx.fragment.app.FragmentManager.execSingleAction(androidx.fragment.app.FragmentManager$OpGenerator, boolean) (FragmentManager.java:1971)
at void androidx.fragment.app.BackStackRecord.commitNowAllowingStateLoss() (BackStackRecord.java:311)
at void androidx.fragment.app.FragmentPagerAdapter.finishUpdate(android.view.ViewGroup) (FragmentPagerAdapter.java:249)
at void androidx.viewpager.widget.ViewPager.populate(int) (ViewPager.java:1244)
at void androidx.viewpager.widget.ViewPager.setCurrentItemInternal(int, boolean, boolean, int) (ViewPager.java:669)
at void androidx.viewpager.widget.ViewPager.setCurrentItemInternal(int, boolean, boolean) (ViewPager.java:631)
at void androidx.viewpager.widget.ViewPager.setCurrentItem(int, boolean) (ViewPager.java:623)
at boolean crc64720bb2db43a66fe9.TabbedPageRenderer.n_onNavigationItemSelected(android.view.MenuItem) (TabbedPageRenderer.java:-2)
at boolean crc64720bb2db43a66fe9.TabbedPageRenderer.onNavigationItemSelected(android.view.MenuItem) (TabbedPageRenderer.java:129)
at boolean com.google.android.material.navigation.NavigationBarView$1.onMenuItemSelected(androidx.appcompat.view.menu.MenuBuilder, android.view.MenuItem) (NavigationBarView.java:241)
at boolean androidx.appcompat.view.menu.MenuBuilder.dispatchMenuItemSelected(androidx.appcompat.view.menu.MenuBuilder, android.view.MenuItem) (MenuBuilder.java:834)
at boolean androidx.appcompat.view.menu.MenuItemImpl.invoke() (MenuItemImpl.java:158)
at boolean androidx.appcompat.view.menu.MenuBuilder.performItemAction(android.view.MenuItem, androidx.appcompat.view.menu.MenuPresenter, int) (MenuBuilder.java:985)
at void com.google.android.material.navigation.NavigationBarMenuView$1.onClick(android.view.View) (NavigationBarMenuView.java:110)
at boolean android.view.View.performClick() (View.java:8160)
at boolean android.view.View.performClickInternal() (View.java:8137)
at boolean android.view.View.access$3700(android.view.View) (View.java:888)
at void android.view.View$PerformClick.run() (View.java:30236)
at void android.os.Handler.handleCallback(android.os.Message) (Handler.java:938)
at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:99)
at void android.os.Looper.loop() (Looper.java:246)
at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:8653)
at java.lang.Object java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[]) (Method.java:-2)
at void com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run() (RuntimeInit.java:602)
at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:1130)
in call to NewString
from android.view.View crc64720bb2db43a66fe9.FragmentContainer.n_onCreateView(android.view.LayoutInflater, android.view.ViewGroup, android.os.Bundle)
@brettnguyen thanks for the workaround, worked for me!
Just add follow code in caurselpage.xaml.cs will fix it, this is not related to IsBusy:
protected override void OnDisappearing()
{
base.OnDisappearing();
ClearCarousel();
}
@jsuarezruiz do you still need more info on this issue?
Anything?
Anything? This issue still exists and giving me trouble from time to time and need to do some funky workarrounds because the IsBusy = false / true; does not alway help.
This bug produces 3 stacktraces I have overridden 3 methods in my CustomCarouselViewRenderer This
protected override void UpdateAdapter()
{
try
{
base.UpdateAdapter();
}
catch (ArgumentOutOfRangeException e)
{
System.Diagnostics.Debug.WriteLine(e));
}
}
produces this
System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index
at object System.Collections.Generic.List<object>.get_Item(int index) in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/Common/src/CoreLib/System/Collections/Generic/List.cs:line 161
at object System.Collections.Generic.List<object>.System.Collections.IList.get_Item(int index) in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/Common/src/CoreLib/System/Collections/Generic/List.cs:line 188
at object Xamarin.Forms.Platform.Android.ObservableItemsSource.ElementAt(int index)
at object Xamarin.Forms.Platform.Android.ObservableItemsSource.GetItem(int position)
at void Xamarin.Forms.Platform.Android.CarouselViewRenderer.SetCurrentItem(int carouselPosition)
at void Xamarin.Forms.Platform.Android.CarouselViewRenderer.UpdateInitialPosition()
at void Xamarin.Forms.Platform.Android.CarouselViewRenderer.UpdateAdapter()
at void Renderers.CustomCarouselViewRenderer.UpdateAdapter() in D:/<>/Renderers/CustomCarouselViewRenderer.android.cs:line 34
This
protected override void SetUpNewElement(ItemsView newElement)
{
try
{
base.SetUpNewElement(newElement);
}
catch (ArgumentOutOfRangeException e)
{
System.Diagnostics.Debug.WriteLine(e);
}
}
produces this
System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index
at object System.Collections.Generic.List<object>.get_Item(int index) in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/Common/src/CoreLib/System/Collections/Generic/List.cs:line 161
at object System.Collections.Generic.List<object>.System.Collections.IList.get_Item(int index) in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/Common/src/CoreLib/System/Collections/Generic/List.cs:line 188
at object Xamarin.Forms.Platform.Android.ObservableItemsSource.ElementAt(int index)
at object Xamarin.Forms.Platform.Android.ObservableItemsSource.GetItem(int position)
at void Xamarin.Forms.Platform.Android.CarouselViewRenderer.SetCurrentItem(int carouselPosition)
at void Xamarin.Forms.Platform.Android.CarouselViewRenderer.UpdateInitialPosition()
at void Xamarin.Forms.Platform.Android.CarouselViewRenderer.SetUpNewElement(ItemsView newElement)
at void Renderers.CustomCarouselViewRenderer.SetUpNewElement(ItemsView newElement) in D:/<>/CustomCarouselViewRenderer.android.cs:line 49
This
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs changedProperty)
{
try
{
base.OnElementPropertyChanged(sender, changedProperty);
}
catch (IndexOutOfRangeException e)
{
System.Diagnostics.Debug.WriteLine(e);
}
}
produces this
System.IndexOutOfRangeException: Can't set CarouselView to position -1. ItemsSource has 1 items.
at void Xamarin.Forms.Platform.Android.CarouselViewRenderer.UpdateFromPosition()
at void Xamarin.Forms.Platform.Android.CarouselViewRenderer.OnElementPropertyChanged(object sender, PropertyChangedEventArgs changedProperty)
at void Renderers.CustomCarouselViewRenderer.OnElementPropertyChanged(object sender, PropertyChangedEventArgs changedProperty) in D:/<>/Renderer/CustomCarouselViewRenderer.android.cs:line 71
I think this mainly happens because the ItemSource
is cleared (not set to null) while the CurrentItem
is still holding the old item. One of the methods in the renderer, probably UpdateInitialPosition
, tries to find the old item in the empty item source and produces the index -1 which causes the issue.
The solution is to set the the carroussel in a view model. I had the same issue and I solve it by doing that. Just make sure that the PressedGestureRecognizer works as weel
Description
After updating the ObservableCollection which is bound to CarouselView, rendering the page with the carousel view gives a crash. Android only. iOS works as expected.
Exception message: [Bug] System.IndexOutOfRangeException: 'Can't set CarouselView to position -1. ItemsSource has X items.' X can be any positive number, its the count of the updated ObservableCollection.
Its a Xamarin exception. I do not call the Position property.
Steps to Reproduce
I do not get a stack trace. So i have no clue where it originates.
Expected Behavior
That the app does not crash. Like it does in iOS. And the carousel shows the updated collection.
Actual Behavior
Basic Information
Environment
Code
My .XAML
Screenshots
N.a.
Workaround
Sadly no. No working workaround so far. Tried all kinds of things (like building it programmatically) but run into another issue where the carousel would not center and was always on top of the screen spite of being a 1:1 copy of the .XAML.