Beispiel #1
0
        protected override void OnElementChanged(ElementChangedEventArgs <ListView> e)
        {
            base.OnElementChanged(e);

            if (e.OldElement != null)
            {
                e.OldElement.ItemSelected      -= OnElementItemSelected;
                e.OldElement.ScrollToRequested -= OnElementScrollToRequested;
                ((ITemplatedItemsView <Cell>)e.OldElement).TemplatedItems.CollectionChanged -= OnCollectionChanged;
                if (Control != null)
                {
                    Control.Loaded -= ControlOnLoaded;
                }
            }

            if (e.NewElement != null)
            {
                e.NewElement.ItemSelected      += OnElementItemSelected;
                e.NewElement.ScrollToRequested += OnElementScrollToRequested;
                ((ITemplatedItemsView <Cell>)e.NewElement).TemplatedItems.CollectionChanged += OnCollectionChanged;

                if (List == null)
                {
                    List = new ListViewTransparent
                    {
                        IsSynchronizedWithCurrentItem = false,
                        ItemTemplate       = (global::Windows.UI.Xaml.DataTemplate)WApp.Current.Resources["CellTemplate"],
                        HeaderTemplate     = (global::Windows.UI.Xaml.DataTemplate)WApp.Current.Resources["View"],
                        FooterTemplate     = (global::Windows.UI.Xaml.DataTemplate)WApp.Current.Resources["View"],
                        ItemContainerStyle = (global::Windows.UI.Xaml.Style)WApp.Current.Resources["FormsListViewItem"],
                        GroupStyleSelector = (GroupStyleSelector)WApp.Current.Resources["ListViewGroupSelector"]
                    };

                    List.SelectionChanged += OnControlSelectionChanged;
                }

                ReloadData();

                UpdateGrouping();
                UpdateHeader();
                UpdateFooter();
                UpdateSelectionMode();
                UpdateWindowsSpecificSelectionMode();
                ClearSizeEstimate();
                UpdateVerticalScrollBarVisibility();
                UpdateHorizontalScrollBarVisibility();

                if (Control != null)
                {
                    Control.Loaded += ControlOnLoaded;
                }
            }
        }
Beispiel #2
0
        protected override void Dispose(bool disposing)
        {
            if (_disposed)
            {
                return;
            }

            _disposed = true;

            if (disposing)
            {
                if (List != null)
                {
                    foreach (ViewToRendererConverter.WrapperControl wrapperControl in FindDescendants <ViewToRendererConverter.WrapperControl>(List))
                    {
                        wrapperControl.CleanUp();
                    }

                    if (_subscribedToTapped)
                    {
                        _subscribedToTapped = false;
                        List.Tapped        -= ListOnTapped;
                    }
                    if (_subscribedToItemClick)
                    {
                        _subscribedToItemClick = false;
                        List.ItemClick        -= OnListItemClicked;
                    }

                    List.SelectionChanged -= OnControlSelectionChanged;
                    if (_collectionViewSource != null)
                    {
                        _collectionViewSource.Source = null;
                    }

                    List.DataContext = null;

                    // Leaving this here as a warning because setting this to null causes
                    // an AccessViolationException if you run Issue1975
                    // List.ItemsSource = null;

                    List = null;
                }

                if (_zoom != null)
                {
                    _zoom.ViewChangeCompleted -= OnViewChangeCompleted;
                    _zoom = null;
                }
            }

            base.Dispose(disposing);
        }