I have made a combobox and used the following code
private void SearchOptionCombobox_DropDownClosed(object sender, EventArgs e) { foreach (SearchOptionItem soi in SearchOptionCombobox.Items) soi.IsShowContent = false; } private void SearchOptionCombobox_DropDownOpened(object sender, EventArgs e) { foreach (SearchOptionItem soi in SearchOptionCombobox.Items) { if (soi.Name == SelectedSearchOption) soi.IsShowContent = true; else soi.IsShowContent = false; } } private void SearchOptionCombobox_SelectionChanged(object sender, SelectionChangedEventArgs e) { SelectedSearchOption = (SearchOptionCombobox.SelectedItem as SearchOptionItem).Name; }
IsShowContent is used to show a tick marker in front of the selected item.
But when I open the combobox, nothing is shown in front of the selected item.
SelectedSearchOption does have the right value and soi.IsShowContent = true is being called.
When I replace
if (soi.Name == SelectedSearchOption)
with
if (soi.Name == "Title")
where "Title" is one of the items, then the tick mark is shown in front of "Title" when I open the combobox.
Why is SelectedSearchOption not working?