Reputation:
I have an ObservableCollection<DiscoveredScooter> DiscoveredScooters = new ObservableCollection<DiscoveredScooter>
. The DiscoveredScooter class looks like this:
public class DiscoveredScooter : ViewModel
{
public string Id { get; set; }
public string Name { get; set; }
public string Model { get; set; }
public int RSSI { get; set; }
public DiscoveredScooter(string id, string name, string model, int rssi)
{
Id = id;
Name = name;
Model = model;
RSSI = rssi;
}
public void Update(DeviceInformationUpdate d, string model, int rssi)
{
Id = d.Id;
RSSI = rssi;
Model = model;
RaisePropertyChanged(nameof(Id));
RaisePropertyChanged(nameof(RSSI));
RaisePropertyChanged(nameof(Model));
}
public void UpdateRSSI(int rssi)
{
RSSI = rssi;
RaisePropertyChanged(nameof(RSSI));
}
}
My XAML has a Listview which is bound to this ObservableCollection. I have a BluetoothAdvertismentEvent that gets fired whenever I receive advertisement data. I do some validation and then I do
await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => {
DiscoveredScooters.Add(new DiscoveredScooter(args.BluetoothAddress.ToString(), bleDeviceName, beaconParser.HumanReadableModel, (int)args.RawSignalStrengthInDBm));
});
But this causes a "XAML generated UnhandledException" and it doesn't say any more about the error whatsoever. Here is a screenshot https://gyazo.com/42ee2cae9018c05087335f77db83cb99 Any help is appreciated.
Upvotes: 0
Views: 58
Reputation:
The issue was that I was using .Substring(41) on a property, where the length was way less than that.
Upvotes: 1