/// <summary> /// This is called when the ItemsPanel property is changed. We need to clear the old object and /// fill our data into the new one. /// </summary> /// <param name="oldValue">Old panel</param> /// <param name="newValue">New panel</param> private void OnItemsPanelPropertyChanged(Xamarin.Forms.Layout <View> oldValue, Xamarin.Forms.Layout <View> newValue) { this.Content = null; // temporarily show nothing. if (stack != null) { stack.Children.Clear(); if (newValue != null) { stack = null; } } if (oldValue != null) { oldValue.Children.Clear(); } // Will recreate the container if necessary FillContainer(newValue, ItemsSource, ItemTemplate); }