Skip to content

Collection View not populating with Observable Collection in Android #25633

Open

Description

Description

I have a collection view that is bonded to an observable collection that populates with nearby BT devices.

Steps to Reproduce

This is a larger app, so I have not recreated the issue elsewhere. I will gladly share the GitHub repo if needed. This is a mini snippet of the code.

VIEW

     if (!ignore)
     {
             try
             {
                         _vm.AvailableDevices.Add(deviceObj);
                         Console.WriteLine(device.Name);
             }
            catch (Exception ex)
            {
                         Console.WriteLine(ex);
            }
     }

VIEW MODEL

        IDevice _device;
        
        public IDevice DeviceInterface { get => _device; }
        public string Name { get => _device.Name; }


          public Device(IDevice device)
        {
            _device = device;
        }
    }
    public class BTDeviceListPopupViewModel : BaseViewModel
    {
        private ObservableCollection<Device> _availableDevices = new ObservableCollection<Device>();
        private bool _isScanning;
        public ObservableCollection<Device> AvailableDevices { get => _availableDevices; 
                                                               set { _availableDevices = value; 
                                                                    OnPropertyChanged(nameof(AvailableDevices)); }  }`

Link to public reproduction project repository

https://github.com/ISSPRO-Eng/MauiProductionProgrammer (Currently Private)(Can make public if needed).

Version with bug

8.0.82 SR8.2

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

All Android Devices

Did you find any workaround?

When I touch/scroll the collection view, it populates with all of the nearby devices. I can clearly see in the code the binding being updated with each device, but it does not show on the screen. This does not happen in iOS devices.

Relevant log output

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions