OnPropertyChanged sometimes does not update UI in ListView, only after scroll or another activity

OksArtOksArt Member

i have a problem, when i work with list items, listview does not redraw them if they area of visibility, reflected only after I've scrolled the element out of view and back, or I've tap on item, it appeared after the updated to Xamarin v4, when i used Xamarin v3 everything was good

i have video this bug but I cant add link ((

Model.cs

     bool _CheckBoxIsVisible = false;
                public bool CheckBoxIsVisible
                {
                    get
                    {
                        return _CheckBoxIsVisible;
                    }
                    set
                    {
                        if (_CheckBoxIsVisible != value)
                        {
                            _CheckBoxIsVisible = value;
                            OnPropertyChanged("CheckBoxIsVisible");
                        }
                    }
                }

        #region INotifyPropertyChanged Implementation
                public event PropertyChangedEventHandler PropertyChanged;
                void OnPropertyChanged([CallerMemberName] string propertyName = "")
                {
                    if (PropertyChanged == null)
                        return;

                    PropertyChanged.Invoke(this, new PropertyChangedEventArgs(propertyName));
                }
                #endregion

container.xaml

<controls:CheckBox Grid.Row="0" Grid.RowSpan="2" Grid.Column="0" Margin="5,0,5,0" Type="Check" IsVisible="{Binding CheckBoxIsVisible}" IsChecked="{Binding IsSelect}" VerticalOptions="Center" HorizontalOptions="Center" />

container.cs

    public ObservableCollection<MailModel> Items = new ObservableCollection<MailModel>();
        MailItemsListView.ItemsSource = Items;


    foreach (var item in Items)
                        {
                            item.CheckBoxIsVisible= true;
                        }

Answers

  • OksArtOksArt Member

    youtu.be/u-a1cWKywKI

  • JarvanJarvan Member, Xamarin Team Xamurai
    edited July 10

    listview does not redraw them...Xamarin v4, when i used Xamarin v3 everything was good

    I created a basic demo on Xamarin v4 to reproduce the problem, it works well. Below is my code, you can check it.

    Or would you mind sharing a repro sample? It'll help to reproduce the issue and get a solution.

Sign In or Register to comment.