コード例 #1
0
        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;
            });
        }
コード例 #2
0
        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;
            });
        }