Quantcast
Channel: Silverlight 5 forum
Viewing all articles
Browse latest Browse all 1083

Set style for SelectedItem when opening ComboBox

$
0
0

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?


Viewing all articles
Browse latest Browse all 1083

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>