Beispiel #1
0
        protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            // In Xamarin Forms > 3.0 this method is called when leaving the current view which in
            // turn results in setting the adapter object even if the view has been destroyed.
            // So explicitly return this method when Items are null;
            if (sender.GetType() == typeof(MultiLevelListView))
            {
                var multiViewCtl = (MultiLevelListView)sender;
                if (multiViewCtl.Items == null)
                {
                    return;
                }
            }

            base.OnElementPropertyChanged(sender, e);
            if (e.PropertyName == MultiLevelListView.ItemsProperty.PropertyName)
            {
                _expandableListViewDataAdaptor = new ExpandableListViewDataAdaptor(this.Context as Activity, Element);

                Control.SetAdapter(_expandableListViewDataAdaptor);
            }
            if (e.PropertyName == MultiLevelListView.ChildSelectedCommandProperty.PropertyName)
            {
                var selectedItem = Element.Items[((ExpandableListViewEventArgs)e).GroupPosition].ChildItems[((ExpandableListViewEventArgs)e).ChildPosition];
                Element.ChildSelectedCommand?.Execute(selectedItem);
            }
        }
Beispiel #2
0
        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);

            if (_expandableListViewDataAdaptor != null)
            {
                _expandableListViewDataAdaptor.Dispose();
                _expandableListViewDataAdaptor = null;
            }
        }
Beispiel #3
0
        protected override void OnElementChanged(ElementChangedEventArgs <MultiLevelListView> e)
        {
            base.OnElementChanged(e);

            var control = new ExpandableListView(this.Context);

            if (e.NewElement != null)
            {
                _expandableListViewDataAdaptor = new ExpandableListViewDataAdaptor(this.Context as Activity, e.NewElement);
                control.SetAdapter(_expandableListViewDataAdaptor);
                control.SetGroupIndicator(null);
                control.SetOnGroupExpandListener(this);
                control.SetOnGroupCollapseListener(this);
                control.SetOnChildClickListener(this);
            }

            SetNativeControl(control);
        }