Binding ComboBox items to GetAvailableAudioCaptureDevices and SelectedItem to AudioCaptureDevice doesn't work RRS feed

  • Question

  • I have a screen that allows users to select which mic they'd like to record with. I'm populating the ItemsSource using CaptureDeviceConfiguration.GetAvailableAudioCaptureDevices and setting the SelectedItem using CaptureSource.AudioCaptureDevice. When the user selects an item from the drop down, it does update the AudioCaptureDevice as expected. However, when the user navigates away from the screen and then comes back again, nothing is selected in the ComboBox. It seems the issue is that multiple calls to GetAvailableAudioCaptureDevices returns new instances of the AudioCaptureDevices. This causes the current AudioCaptureDevice to not "equal" any items in the list returned from GetAvailableAudioCaptureDevices, even though one of the items in the list effectively represents the same underlying device. The question is... is this the expected behavior or is this a bug with the beta? If this is the expected behavior I think I'll need to create a wrapper for AudioCaptureDevices that overrides "Equals" in order for the ComboBox to work the way I would like. If this will be changed in the next release, I'll leave my project alone. Thanks for any feedback :)

    Tuesday, December 8, 2009 11:05 PM


  • Hi Eric,

    set the SelectedValuePath-Property on your ComboBox to "FriendlyName".

    When the ComboBox is filled up, don't set SelectedItem, set SelectedValue instead like this:

    combo.SelectedValue = yourAudioCaptureDevice.FriendlyName;

    The SelectedItem-Property will contain the right instance.

    Wednesday, December 9, 2009 5:19 AM