Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3284828
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T20:11:53+00:00 2026-05-17T20:11:53+00:00

I am trying to set the selected item in my silverlight combobox from a

  • 0

I am trying to set the selected item in my silverlight combobox from a string.

In this example lets say I have a combobox named “MyComboBox” as follows:

<ComboBox Height="23" x:Name="MyComboBox" Width="200" HorizontalAlignment="Left">
    <ComboBoxItem Tag="0" Content="Pizza" IsSelected="True"/>
    <ComboBoxItem Tag="1" Content="Soda"/>
    <ComboBoxItem Tag="2" Content="Wings"/>
    <ComboBoxItem Tag="3" Content="Bread Sticks"/>
</ComboBox>

I am randomly selecting a string value above from a list to simulate a users saved preference. The problem I am facing is trying to grab the index of “MyComboBox” from a string.

I’ve tried using MyComboBox.items wtih LINQ but that has taken me nowhere.

There are some similar questions here on stack overflow but none of these have been answered.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T20:11:54+00:00Added an answer on May 17, 2026 at 8:11 pm

    If you have a reason that you have to wrap the strings in ComboBoxItem then this should work.

    MyComboBox.Items.SelectedItem = 
        MyComboBox.Items.SingleOrDefault(c => (c as ComboBoxItem).Content == myString);
    

    I would recommend to not directly insert ComboBoxItem and set items to String or setup a collection in code and bind to it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to set the selected value of a combobox from a style
I am trying to set selected item of comboBox on click event of DataGrid,
I'm trying to set the index of the item that needs to be selected
I'm trying to set seletected value to a pre-loaded combobox using silverlight with MVVM.
I'm trying to set a variable to the value of the selected item in
I am trying to get a selected item from a dropdown list in the
I'm trying to set a combobox's dataprovider. I have 2 comboboxes: cb_div and cb_stores.
I am trying to implement custom ObservableCollection Which will have current (selected) item property
In WinForm, I have a ComboBox. I am trying to do something like this.
I am trying to set selectedItem on a comboBox(mx). Following is the code :

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.