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

Removing and reinserting the same ScrollView causes WinPhone exception

$
0
0

Create a simple page with some container, let's say a stacklayout. Add a scrollviewer as a Child of that stacklayout. Remove the scrollviewer (but keep it in memory). Now put the Scrollviewer back on it's original Place, EXCEPTION!

This is ONLY the case on Windows Phone (not Android or iOS). It's also olnly the case if the removed control is a ScrollView. Replace it with a label, a stackpanel or something else and it works fine.

In the example below, pressing button TWO, then ONE then TWO will throw the exception!

Can someone please confirm this and perhaps report it as a bug?

============ EXAMPLE ======================
The xaml was attached as an image since I didn't manage to make it visible in the forum

        using System;
        using Xamarin.Forms;

        namespace ChangeContentTest
        {
            public partial class PageOne : ContentPage
            {
                private ScrollView _scrollView;

                public PageOne()
                {
                    InitializeComponent();

                    _scrollView = new ScrollView
                    {
                        Content = new StackLayout
                        {
                            Children = { new Label
                            {
                                Text = "This is the scroll view"
                            }}
                        }
                    };
                }

                private void ButtonOne_OnClicked(object sender, EventArgs e)
                {
                    TheStack.Children.Clear();
                }

                private void ButtonTwo_OnClicked(object sender, EventArgs e)
                {
                    TheStack.Children.Add(_scrollView);
                }
            }
        }

Viewing all articles
Browse latest Browse all 58056

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>