Quantcast
Channel: Active questions tagged listview - Stack Overflow
Viewing all articles
Browse latest Browse all 611

Updating listview text binding causes flickering on iOS using Xamarin.Forms

$
0
0

I am working on a Xamarin.Forms chat app which sends/receives text character by character, this means the text binding on a list view row is updated every 1-2 seconds or half second (depending on typing speed), on Android the listview item updates smoothly but on iOS it flickers/ and pulsates like a strobe light with every character entered.

EditReplication steps:Bound a Listview's ItemSource to an ObservableCollection which updates for every new character typed in an Entry. Use DataTemplate with a label in it which displays the text typed in Entry field.

In Page.xaml

<ListView HasUnevenRows="True" ItemsSource="{Binding ObservableCollection}"><ListView.ItemTemplate><DataTemplate><ViewCell><ViewCell.View><Grid><Label Text="{Binding Text}"/></Grid></ViewCell.View></ViewCell></DataTemplate></ListView.ItemTemplate></ListView><Entry Text="{Binding UserText}"/>

In PageViewModel.cs

    /// <summary>    /// Gets or sets the text entered by the user    /// </summary>    public string UserText    {        get        {            return this.userText;        }        set        {            this.SetProperty(ref this.userText, value);            // Display text by updating listview            Device.BeginInvokeOnMainThread(() =>            {                this.ObservableCollection.Add(userText);            });        }    }          

Viewing all articles
Browse latest Browse all 611

Trending Articles