private async void OnDeviceAdd(DeviceWatcher sender, DeviceInformation args) { await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() => { // Add each discovered device to the list var addedDevice = await CastingDevice.FromIdAsync(args.Id); CastingDevices.Add(addedDevice); NoDevicesTextBlock.Visibility = CastingDevices.Count == 0 ? Visibility.Visible : Visibility.Collapsed; }); }
private async void OnDeviceRemove(DeviceWatcher sender, DeviceInformationUpdate args) { await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { foreach (var currentDevice in CastingDevices) { if (currentDevice.Id == args.Id) { CastingDevices.Remove(currentDevice); } } NoDevicesTextBlock.Visibility = CastingDevices.Count == 0 ? Visibility.Visible : Visibility.Collapsed; }); }