Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How do you dynamically update a collection view in .net maui?

I have a test app im working with and im populating the collection view with a sqlite DB. But whenever I use a swipe view to delete the item from the database it works fine but the view never removes the item from the collection view unless the entire view is reloaded. I’ve tried a few different things, but nothing has any effect, Any recommendations? Would the OnAppearing life cycle cause any issues?

 <Grid BackgroundColor="White">
        <StackLayout Margin="20">
            <CollectionView x:Name="data"
                            SelectionMode="Single"
                            SelectionChanged="ItemSelected"
                            HeightRequest="750"
                            VerticalScrollBarVisibility="Never">

protected override async void OnAppearing()
    {
        base.OnAppearing();
        TodoItemDatabase database = await TodoItemDatabase.Instance;
        data.ItemsSource = await database.GetItemsAsync();
    }

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

From the docs

If the CollectionView is required to refresh as items are added,
removed, or changed in the underlying collection, the underlying
collection should be an IEnumerable collection that sends property
change notifications, such as ObservableCollection.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading