ListView items get updated only after scrolled back into view - Xamarin Forms

AbsoluteSith

I have created a listview which has children whose background is bound to itemssource.

This works well on Android with the PropertyChanged event called.

But unfortunately it doesn't work as smooth on iOS the background change gets reflected only after I've scrolled the element out of view and back into the view to redraw it.

Is there any other way I can make the content refresh manually?

Code:

<ListView x:Name="ListView" ItemsSource="{Binding ListSource}" RowHeight="50">
        <ListView.ItemTemplate>
          <DataTemplate>
            <ViewCell>
              <ViewCell.View>
                <ContentView Padding="10" BackgroundColor="{Binding BackgroundColor}">
                  <Label Text="{Binding Name}" HorizontalOptions="Center" TextColor="White" />
                </ContentView>
              </ViewCell.View>
            </ViewCell>
          </DataTemplate>
        </ListView.ItemTemplate>
      </ListView>

Handling the itemclick to change the background and remove the selecteditem.

ListView.ItemTapped += async (s, e) =>
{
    var list = ListSource;

    var listItem = list.First(c => c.Id == ((ListItem)e.Item).Id);

    listItem.Selected = !listItem.Selected;

    SelectListSource = list;

    ListView.SelectedItem = null;

};

Code in the model :

    public Boolean Selected
    {
        get
        {
            return _selected;
        }
        set
        {
            _selected = value;
            if (PropertyChanged != null)
                PropertyChanged(this, new PropertyChangedEventArgs("BackgroundColor"));
        }
    }                 

    public Color BackgroundColor
    {
        get
        {
            if (Selected)
                return Color.Black;
            else
                return Color.Blue
        }
    }
AbsoluteSith

Ok so I found a work around by using XFGloss.

Added Binding to the ViewCell with the help of this nuget.

<ViewCell xfg:CellGloss.BackgroundColor="{Binding BackgroundColor}">

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Prism Xamarin Forms View is not updated after changing the model in OnNavigatedTo

From Dev

Xamarin.Forms: Get all cells/items of a listview

From Dev

Padding between items in Xamarin.Forms ListView

From Dev

ListView not updated after adding new items to List

From Dev

Xamarin Forms - ListView IsVisible bound to Switch, only shows entire ListView after 2 switches

From Dev

Xamarin Forms: access View of databound ListView item?

From Dev

Xamarin.Forms - ListView isn't being updated in the OnAppearing method

From Dev

Razor view is only updated after build

From Dev

Xamarin Forms: Get control inside a listview

From Dev

Xamarin Forms - Get position of item selected in Listview

From Dev

Xamarin Forms: Get control inside a listview

From Dev

How to get children of the ListView in xamarin.forms?

From Dev

How To Get Children of Xamarin Forms Listview

From Dev

I am losing values from ListView items that have been scrolled out of view

From Dev

After scrolling listView Items View elements mixed with

From Dev

Xamarin Forms - Show Cancel button in toolbar items instead of Back (iOS)

From Dev

Can I reorder the ListView items on the Run in Xamarin.Forms?

From Dev

Can I reorder the ListView items on the Run in Xamarin.Forms?

From Dev

How to tell if height of ListView items is bigger than heigh of actual ListView (i.e. can the list view be scrolled)?

From Dev

Angular View not updated after data is back from observable

From Dev

Xamarin Forms List View Showing Row items in Frames

From Dev

Xamarin Forms Access Listview

From Dev

Xamarin Forms ListView Checkmark

From Dev

Xamarin Forms listview databinding

From Dev

Xamarin Forms ListView Binding

From Dev

Play video only when scrolled into view

From Dev

Xamarin.Forms could not be updated

From Dev

Get coordinates within listview when scrolled down

From Dev

View only updated by EnvironmentObject after App-restart

Related Related

  1. 1

    Prism Xamarin Forms View is not updated after changing the model in OnNavigatedTo

  2. 2

    Xamarin.Forms: Get all cells/items of a listview

  3. 3

    Padding between items in Xamarin.Forms ListView

  4. 4

    ListView not updated after adding new items to List

  5. 5

    Xamarin Forms - ListView IsVisible bound to Switch, only shows entire ListView after 2 switches

  6. 6

    Xamarin Forms: access View of databound ListView item?

  7. 7

    Xamarin.Forms - ListView isn't being updated in the OnAppearing method

  8. 8

    Razor view is only updated after build

  9. 9

    Xamarin Forms: Get control inside a listview

  10. 10

    Xamarin Forms - Get position of item selected in Listview

  11. 11

    Xamarin Forms: Get control inside a listview

  12. 12

    How to get children of the ListView in xamarin.forms?

  13. 13

    How To Get Children of Xamarin Forms Listview

  14. 14

    I am losing values from ListView items that have been scrolled out of view

  15. 15

    After scrolling listView Items View elements mixed with

  16. 16

    Xamarin Forms - Show Cancel button in toolbar items instead of Back (iOS)

  17. 17

    Can I reorder the ListView items on the Run in Xamarin.Forms?

  18. 18

    Can I reorder the ListView items on the Run in Xamarin.Forms?

  19. 19

    How to tell if height of ListView items is bigger than heigh of actual ListView (i.e. can the list view be scrolled)?

  20. 20

    Angular View not updated after data is back from observable

  21. 21

    Xamarin Forms List View Showing Row items in Frames

  22. 22

    Xamarin Forms Access Listview

  23. 23

    Xamarin Forms ListView Checkmark

  24. 24

    Xamarin Forms listview databinding

  25. 25

    Xamarin Forms ListView Binding

  26. 26

    Play video only when scrolled into view

  27. 27

    Xamarin.Forms could not be updated

  28. 28

    Get coordinates within listview when scrolled down

  29. 29

    View only updated by EnvironmentObject after App-restart

HotTag

Archive