예제 #1
0
        protected override void OnAttachedTo(ContentPage bindable)
        {
            ListView         = bindable.FindByName <SfListView>("ListView");
            ListView.Loaded += ListView_Loaded;
            visualContainer  = ListView.GetVisualContainer();

            base.OnAttachedTo(bindable);
        }
예제 #2
0
        protected override void OnAttachedTo(ContentPage bindable)
        {
            ListView        = bindable.FindByName <SfListView>("listView");
            Button          = bindable.FindByName <Button>("scrollButton");
            Container       = ListView.GetVisualContainer();
            Button.Clicked += Button_Clicked;

            base.OnAttachedTo(bindable);
        }
예제 #3
0
        protected override void OnAttachedTo(ContentPage bindable)
        {
            ListView = bindable.FindByName <SfListView>("listView");
            VM       = new ContactsViewModel();
            ListView.BindingContext = VM;
            AddButton          = bindable.FindByName <Button>("addItem");
            AddButton.Clicked += AddItem_Clicked;
            visualContainer    = ListView.GetVisualContainer();

            base.OnAttachedTo(bindable);
        }
예제 #4
0
        private void TappedGestureCommandMethod(object obj)
        {
            var tappedItemData = obj as Contact;

            if (TappedItem != null && TappedItem.IsVisible)
            {
                var previousIndex = listView.DataSource.DisplayItems.IndexOf(TappedItem);

                TappedItem.IsVisible = false;

                if (Device.RuntimePlatform != Device.macOS)
                {
                    Device.BeginInvokeOnMainThread(() => { listView.RefreshListViewItem(previousIndex, previousIndex, false); });
                }
            }

            if (TappedItem == tappedItemData)
            {
                if (Device.RuntimePlatform == Device.macOS)
                {
                    var previousIndex = listView.DataSource.DisplayItems.IndexOf(TappedItem);
                    Device.BeginInvokeOnMainThread(() => { listView.RefreshListViewItem(previousIndex, previousIndex, false); });
                }

                TappedItem = null;
                return;
            }

            TappedItem           = tappedItemData;
            TappedItem.IsVisible = true;

            if (Device.RuntimePlatform == Device.macOS)
            {
                var visibleLines = listView.GetVisualContainer().ScrollRows.GetVisibleLines();
                var firstIndex   = visibleLines[visibleLines.FirstBodyVisibleIndex].LineIndex;
                var lastIndex    = visibleLines[visibleLines.LastBodyVisibleIndex].LineIndex;
                Device.BeginInvokeOnMainThread(() => { listView.RefreshListViewItem(firstIndex, lastIndex, false); });
            }
            else
            {
                var currentIndex = listView.DataSource.DisplayItems.IndexOf(tappedItemData);
                Device.BeginInvokeOnMainThread(() => { listView.RefreshListViewItem(currentIndex, currentIndex, false); });
            }
        }