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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:41:53+00:00 2026-05-26T11:41:53+00:00

I am using the MVVM pattern to bind a ComboBox SelectedIndex value to an

  • 0

I am using the MVVM pattern to bind a ComboBox SelectedIndex value to an int in the view model:

<ComboBox ItemsSource="{Binding DropdownListChoices}" Margin="5,2,5,1" Width="320" Height="23"
 Style="{StaticResource comboBoxWithErrorHandling}" SelectedIndex="{Binding SelectedComboBoxIndex}">

View model:

public class FieldViewModel : ObservableObject, IDataErrorInfo
{
    private int _selectedComboBoxIndex;

    public int SelectedComboBoxIndex
    {    
        get { return _selectedComboBoxIndex; }
        set
        {
            if (_selectedComboBoxIndex != value)
            {
                _selectedComboBoxIndex = value;
                RaisePropertyChanged("SelectedComboBoxIndex");
            }
        }
    }   

    // ...  
}

In a different part of the code, I populate DropdownListChoices. Let’s say the elements are for instance A, B, C, A, D. Selecting B, C or D correctly causes SelectedComboBoxIndex to get the expected value (1, 2 or 4, respectively). But selecting A will set SelectedComboBoxIndex to 0, regardless of whether the first or the second A was selected. On selecting the second A, I would expect the selected index to be 3.

Why does this happen? Is there a different way of achieving what I’m trying to do, namely to get the absolute list index which was selected?

  • 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-26T11:41:53+00:00Added an answer on May 26, 2026 at 11:41 am

    You should never have duplicate items in selector-controls, it will only confuse them and cause anomalies, if you have primitive values wrap them in a class.

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

Sidebar

Related Questions

I am following MVVM Pattern and I want to bind ListView ItemsSource using XAML,
I'm writing a Silverlight app using the MVVM pattern. I have a main view
I'm using the MVVM pattern and I have a POCO (in my Model) with
I'm trying to set up some binding. And FYI I'm using the MVVM pattern.
i try to use generate MVVM pattern using Silverlight ListView. But if i bind
Using the MVVM pattern creating WPF applications you have the ViewModel providing data to
I'm developing a project using the MVVM pattern in WPF. One of the key
I am writing an application using the MVVM pattern. I am providing data to
My WPF application is structured using the MVVM pattern. The ViewModels will communicate asynchronously
I'm working on a Silverlight app using the MVVM pattern. My ViewModel currently consists

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.