I want to create a ComboBox
control in code (no XAML) which displays the list of available AudioCaptureDevice
s.
ReadOnlyCollection<AudioCaptureDevice> audioDevices;
audioDevices = CaptureDeviceConfiguration.GetAvailableAudioCaptureDevices();
StackPanel sp = new StackPanel();
ComboBox cbxAudioDevices = new ComboBox();
cbxAudioDevices.ItemsSource = audioDevices;
sp.Children.Add(cbxAudioDevices);
this.RootVisual = sp;
However, instead of displaying nice-looking names, only entries named System.Windows.Media.AudioCaptureDevice are shown.
The nice-looking names would be available through the FriendlyName
property of the AudioCaptureDevice
.
Is there an easy way to convert my collection so that it will display the friendly names, but will still hold the AudioCaptureDevice
s? Or will I have to create a second collection with only the names, and then take my original collection to get the other properties?