or
if (!box.Text.Equals(value)) // <- Here appears exception
{ box.OpenDropDown(false); box.Refresh(); ComboBoxItem item = box.Items.FirstOrDefault(i => i.Text.Trim().Contains(value.TrimValue())); Stopwatch watch = Stopwatch.StartNew(); while (item == null && watch.ElapsedMilliseconds < 30000) { box.Refresh(); item = box.Items.FirstOrDefault(i => i.Text.Trim().Contains(value.TrimValue())); } watch.Stop(); if (item != null) { item.IsSelected = true; box.IsDropDownOpen = false; return true; } box.IsDropDownOpen = false; return false; } return true;