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 6666799
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:51:59+00:00 2026-05-26T02:51:59+00:00

I have a combo box like this <ComboBox Name=myMenu> <ComboBoxItem Content=Question 1 Tag=1 />

  • 0

I have a combo box like this

    <ComboBox Name="myMenu">
        <ComboBoxItem Content="Question 1" Tag="1"  />
        <ComboBoxItem Content="Question 2" Tag="2"  />
        <ComboBoxItem Content="Question 3" Tag="3"  />
        <ComboBoxItem Content="Question 4" Tag="4"  />
    </ComboBox>

How can I programmatically set the selected index by Tag Value? E.g. ‘myMenu.selectedTag = 3’ and Question 3 would be the selected item?

I want something easier than my current solution really…

      int tagToSelect = 3;
      foreach (ComboBoxItem item in myMenu.Items)
      {
          if(item.Tag.Equals(tagToSelect)
          {
               myMenu.SelectedItem = item;
          }
      }
  • 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-26T02:52:00+00:00Added an answer on May 26, 2026 at 2:52 am

    Looks like you’re looking for the proeprty SelectedValuePath of ComboBox control. See example here http://msdn.microsoft.com/en-us/library/system.windows.controls.primitives.selector.selectedvaluepath.aspx

    For those people who cannot find example under the link above and keep downvoting I prepared my own example. It highlights how to setup ComboBox and select appropriate item by assigning selected value.

    MainWindow.xaml

    <Window x:Class="WpfApp1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="d" Height="97" Width="202">
    <Window.Resources>
        <XmlDataProvider x:Key="Questions" XPath="/Questions/*">
            <x:XData>
                <Questions xmlns="">
                    <Question Title="Question 1" Index="1" />
                    <Question Title="Question 2" Index="2" />
                    <Question Title="Question 3" Index="3" />
                    <Question Title="Question 4" Index="4" />
                </Questions>
            </x:XData>
        </XmlDataProvider>
        <DataTemplate x:Key="QuestionItemTemplate">
            <TextBlock Text="{Binding XPath=@Title}" />
        </DataTemplate>
    </Window.Resources>
    <StackPanel>
        <ComboBox Name="myMenu"
                  ItemsSource="{Binding Source={StaticResource Questions}}"
                  ItemTemplate="{StaticResource QuestionItemTemplate}"
                  SelectedValuePath="@Index"/>
        <TextBlock Text="{Binding ElementName=myMenu, 
            Path=SelectedValue, StringFormat=Selected Index: {0:D}}"/>
        <Button Content="Select another item" Click="Button_Click" />
    </StackPanel>
    

    MainWindow.xaml.cs

    using System.Windows;
    
    namespace WpfApp1
    {
        /// <summary>
        /// Interaction logic for MainWindow.xaml
        /// </summary>
        public partial class MainWindow : Window
        {
            public MainWindow()
            {
                InitializeComponent();
            }
    
            private void Button_Click(object sender, RoutedEventArgs e)
            {
                myMenu.SelectedValue = ++_counter;
                if (_counter > 3) _counter = 0;
            }
    
            private int _counter = 0;
    
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a view with a ComboBox like this <ComboBox Name=cmbPurpose DisplayMemberPath=@value SelectedValuePath=@key ItemsSource={Binding
I want to have file combo box in delphi. It must behave like this:
I have a ListView that looks like this: The combo box is bound to
So I was have a combobox like below, coded like this; AllowsTransparency=True Background=Transparent> <Border
I have some Company names as Items in a ComboBox like this: 123 SomeCompany
I have a ComboBox with a label function like this one: private function fieldLabelFunction(item:Object):String
I am dynamically creating a combobox like this: public Control GenerateList(Question question) { //
I have a combobox in WPF like this: <ComboBox Text=Select Language... IsEditable=True IsReadOnly=True ItemsSource={Binding
I have created combo box that I would like to load with all of
I have databinding for my comboboxes set up like this: Show Enum Description Instead

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.