0
votes

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.

Edit Replication 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);
            });
        }
    }          
1
We need to see the code of current implementation before anyone will help youLeRoy
@LeRoy I added some code. It seems like a listview Xamarin iOS bug to me as there is no flickering on Android.user2240342
It may be related to some default iOS reload list item animation, just checking now.user2240342

1 Answers

0
votes

I created a ListViewRenderer on iOS and set AnimationsEnabled = false. The flicking is now gone!