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

If I replace cell (trimmed expanded status) UI freeze. How to avoid ?

$
0
0

Hello,
I have a listview with a number of rows in 'trimmed' status (I show only few informations)
When user click on row the cell should expand to a new layout, with several informations...
When I have that the expanded view is really large (for example with 200-300 subrows) the UI freeze for a lot of seconds.

In my PageView I try to put the replace of the cell into a thread (OnItemClick event)

    ...

        new System.Threading.Thread(new System.Threading.ThreadStart(() => {
            Device.BeginInvokeOnMainThread(() => {
                    ViewModel.AZItems[_index] = newazitem; // <- the slow one
            });

        })).Start();


    //  new System.Threading.Thread(new System.Threading.ThreadStart(() => {
 //     ViewModel.AZItems[_index] = newazitem; // <- the slow one
   //   })).Start();

    ...

In my PageViewModel

        private ObservableCollection<AZitem> aZItems = new ObservableCollection<AZitem>();
        public ObservableCollection<AZitem> AZItems
        {
            get { return aZItems; }
            set
            {
                aZItems = value; //OnPropertyChanged();
            }
        }

In my AZCell I have xaml for trimmed layout, and I use code for expanded layout

        protected override void OnBindingContextChanged()
        {
            base.OnBindingContextChanged();
            if (BindingContext == null)
            {
                return;
            }
            var data = (AZitem)BindingContext;

            var expand = data.IsExpanded;

            if (expand)
            {
                SetExpandedView(data);
            }
        }

        private void SetExpandedView(AZitem data)
        {

            Grid grid = new Grid
            {
                // ...
            }
        }

but nothing change..the UI freeze for a lot of seconds...

How can I avoid the freeze of UI ?
Thanks!


Viewing all articles
Browse latest Browse all 89864

Trending Articles



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