public BrowsePage() { InitializeComponent(); Bluetooth = DependencyService.Get <Bluetooth>(); DevicesList.ItemsSource = Bluetooth.GetDevices(); DevicesList.Refreshing += (s, e) => ReScanDevices(); StartSearchDevices(); }
private async Task RefreshDevices() { var devices = (await Bluetooth.GetDevices()).OrderBy(s => s.Name).ToList(); var items = DevicesComboBox.Items.ToList().OfType <DeviceInfo>().OrderBy(s => s.Name).ToList(); if (items.Count == devices.Count && items.SequenceEqual(devices)) { return; } DevicesComboBox.Items?.Clear(); foreach (var item in devices) { DevicesComboBox.Items?.Add(item); if (item.Name == AppSettings.RemoteDevice) { DevicesComboBox.SelectedItem = item; } } }