I am building a new BLE app in Xamarin.Forms, using the Monkey.Robotics component. I am using this Heart Rate sample as a starting point. However, I want a dashboard type homepage, where received characteristics are displayed. Then I want an "add device" button at the bottom, which triggers the scanning and pairing procedure.
I currently have an ObservableCollection<T>
class set up to add all devices found into a list view. I would really like to have all of the functionality on one page, so that I don't complicate the different states, for "have previously paired", "want to pair a new device" and "haven't ever paired". I would ideally like to use a DisplayActionSheet.
This is the given example
var actionButton1 = new Button { Text = "ActionSheet Simple" };
actionButton1.Clicked += async (sender, e) => {
var action = await DisplayActionSheet ("ActionSheet: Send to?", "Cancel", null, "Email", "Twitter", "Facebook");
Debug.WriteLine("Action: " + action); // writes the selected button label to the console
};
Is it possible for me to populate this with the dynamic data coming from the scan through the ObservableCollection?
Here is my current arrangement:
this.devices = new ObservableCollection<IDevice> ();
listView.ItemsSource = devices;
adapter.DeviceDiscovered += (object sender, DeviceDiscoveredEventArgs e) => {
Device.BeginInvokeOnMainThread(() => {
devices.Add (e.Device);
});
};
Suggestions for how I might achieve this would be really appreciated (and whether it is possible, or there is a better way of doing this?), whilst still keeping to the correct structure for the DisplayActionSheet.
Thanks!
NB: I have also been looking at this guide as an alternative, but not sure that it renders natively on each platform.