FlowListView is not updating when remove an item
See original GitHub issueHi guys!
I have a simple scenario which a user can add and remove items from a ObservableCollection in MVVM app.
I have an issue when I have two or more items and remove one item. The UI is not updating. But when all items are removed from ObservableCollection, then the UI is updated clearing the list.
Take a look in the demo:
Here is the (resumed) code:
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:prism="clr-namespace:Prism.Mvvm;assembly=Prism.Forms"
prism:ViewModelLocator.AutowireViewModel="True"
xmlns:converters="clr-namespace:MyApp.Converters;assembly=MyApp"
x:Class="MyApp.Views.MyPage"
x:Name="MyPage">
<ContentPage.Resources>
<ResourceDictionary>
<converters:UrlToImageSourceConverter x:Key="UrlToImageSource" />
</ResourceDictionary>
</ContentPage.Resources>
<StackLayout HorizontalOptions="FillAndExpand" >
<controls:FlowListView FlowColumnCount="3"
SeparatorVisibility="None" VerticalOptions="Start"
HasUnevenRows="True"
FlowItemsSource="{Binding Images}">
<controls:FlowListView.FlowColumnTemplate>
<DataTemplate>
<StackLayout Padding="0,0,0,0">
<Image Source="{Binding Url, Converter=UrlToImageSource}" HeightRequest="90" Margin="0,5,0,5" />
<Button Text="Remove"
Command="{Binding Source={x:Reference MyPage}, Path=BindingContext.RemoveImageCommand}"
CommandParameter="{Binding .}"/>
</StackLayout>
</DataTemplate>
</controls:FlowListView.FlowColumnTemplate>
</controls:FlowListView>
</StackLayout>
</ContentPage>
public class MyPageViewModel : BindableBase
{
private ObservableRangeCollection<MyImage> _imageList = new ObservableRangeCollection<MyImage>();
public DelegateCommand<MyImage> RemoveImageCommand => new DelegateCommand<MyImage>(item => _imageList.Remove(item) );
//...
public ObservableRangeCollection<MyImage> Images
{
get { return _imageList; }
set { SetProperty(ref _imageList, value); }
}
}
public class MyImage
{
public string Url { get; set; }
}
Issue Analytics
- State:
- Created 7 years ago
- Comments:14 (5 by maintainers)
Top Results From Across the Web
FlowListView not fully updating UI when changing ...
When I remove objects from the list the UI doesn't reflect the current state of the list, normally failling by only one item....
Read more >Nested ListView is not updating the delete action on a ...
Hello support, I have the following problem in my ASP.Net WebForms devexpress application. I got a nested list view in a popup window, ......
Read more >ListView - .NET MAUI
If the ListView is required to refresh as items are added, removed, or changed in the underlying collection, the underlying collection ...
Read more >ListView
The ListView widget is an extremely useful widget for displaying a list of items in a linear arrangement (vertical or horizontal).
Read more >Use Flows to Bulk Update Records from List View in ...
In this article, I am going to show how can we remove duplicate records from collection variables or de-duplicate collection variables in ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
+1 Here!!
But, I maked a workaround to solve this until a solution:
1 - Remove the item 2 - Make a copy of your collection 3 - Set this copy in your ObservableCollection at your model
This make to FlowListItens.FlowItemsSource to know that have new collection and refresh the data.
Regards…
Nelson
not working