0

Since we have moved to Asus Transformer tablets, app starts crashing. It throws out null exception when i click on ComboBox to change webcam. There is no error when loading webcams to the ComboBox

WPF:

        <ComboBox x:Name="cams" VerticalAlignment="Bottom" HorizontalAlignment="Center" Width="300" DisplayMemberPath="Name" Margin="10" FontSize="20" FontWeight="Bold"/>

C#

    private void InitializeComboBox()
    {
        cams.ItemsSource = webCameraControl.GetVideoCaptureDevices();

        if (cams.Items.Count > 0)
        {
            cams.SelectedItem = cams.Items[1];
            cams.SelectedIndex = 1;
        }
    }

As I said, there is no error when loading cams to ItemsSource, only when I click on it to change camera

arti
  • 595
  • 4
  • 24
  • 1
    The exact exception might be helpful. Atm. we can't really deduct anything from what you posted. – Adwaenyth Oct 06 '16 at 05:52
  • 1
    There is a bug in the .Net Framework that sometimes happens with the comboboxes and should be fixed with release 4.6.2. See bug ticket : https://connect.microsoft.com/VisualStudio/feedback/details/1660886/system-windows-controls-combobox-coerceisselectionboxhighlighted-bug – lhildebrandt Oct 06 '16 at 06:20
  • there was nullexception. I have fixed it by loading data into separate list and adding only 2 items to combo, probably rest of them are corrupted. Not perfect solution but working for my needs – arti Oct 06 '16 at 06:40
  • You check if there are any elements in `cams.Items` collection, then you take the second one. Check if there are more than one elements or use the first (with index 0) – slawekwin Oct 06 '16 at 06:47
  • need more code to determine potential faults, specifically the combobox's click event handler – Fredrik Oct 06 '16 at 06:54

0 Answers0