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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T04:53:57+00:00 2026-05-15T04:53:57+00:00

C#, .NET 4.0, VS2010. New to WPF. I have a ComboBox on my MainWindow.

  • 0

C#, .NET 4.0, VS2010.

New to WPF. I have a ComboBox on my MainWindow. I hooked the SelectionChanged event of said combo box. However, if I examine the value of the combo box in the event handler, it has the old value. This sounds more like a “SelectionChanging” event, than a SelectionChanged event.

How do I get the new value of the ComboBox after the selection has actually happend?

Currently:

this.MyComboBox.SelectionChanged += new SelectionChangedEventHandler(OnMyComboBoxChanged);

...
private void OnMyComboBoxChanged(object sender, SelectionChangedEventArgs e)
{
    string text = this.MyComboBox.Text;
}

Note, I get the same behaviour if I use the object being passed in the event args, e.g. e.OriginalSource.

  • 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-15T04:53:58+00:00Added an answer on May 15, 2026 at 4:53 am

    According to MSDN, e.AddedItems:

    Gets a list that contains the items that were selected.

    So you could use:

    private void OnMyComboBoxChanged(object sender, SelectionChangedEventArgs e)
    {
        string text = (e.AddedItems[0] as ComboBoxItem).Content as string;
    }
    

    You could also use SelectedItem if you use string values for the Items from the sender:

    private void OnMyComboBoxChanged(object sender, SelectionChangedEventArgs e)
    {
        string text = (sender as ComboBox).SelectedItem as string;
    }
    

    or

    private void OnMyComboBoxChanged(object sender, SelectionChangedEventArgs e)
    {
        string text = ((sender as ComboBox).SelectedItem as ComboBoxItem).Content as string;
    }
    

    Since both Content and SelectedItem are objects, a safer approach would be to use .ToString() instead of as string

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

Sidebar

Related Questions

I am new to WPF, I am using VS2010 beta2, .NET 4.0. Throw new
I have developed a WinForm Application with VB.Net (VS2010) having Office 2010 Professional Installed,
We have a .NET application (VB / VS2010) and are calling many stored procedures
Using WPF .NET 4.0 in VS2010 RTM: I can't create a fullscreen WPF popup.
I have a ASP.NET MVC2 project in VS2010 that can be deployed in two
I have inhherited a vs2010 c# web project (asp.net). It has a web reference
i have a class in c# (.net 3.5 cp, vs2010) which executes complex comuptations
I have encountered something very strange, simple WPF application <Window x:Class=ListBoxSelection.MainWindow xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml Title=MainWindow
Will their be a new release of the compact framework with VS2010 and .net
In VS2010 I have VB.NET codebehind aspx pages and I'm using Ajax multihandleslider extensions

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.