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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:30:42+00:00 2026-05-27T20:30:42+00:00

I have a WPF app that has a combobox with lookup items. The combobox

  • 0

I have a WPF app that has a combobox with lookup items. The combobox is populated with a ObservableCollection property that is created in my ViewModel.

The user can popup a window to type in a new lookup value. After the user enters a new value, I write the value to the lookup table in SQL Server. This part works well.

The problem is, I then want the combobox list to be updated and sorted correctly. What is the best way to do this?

If I do this, myLookupProperty.Add(newitem), my combobox is updated but it’s not in the correct order.

If I do this, myLookupProperty = new ObservableCollection(Context.GetLookupTypes()), then the combobox is not updated until I click off the combobox and then back onto it.

Whats the best way to get newly inputted items into the table and have the combobox get these changes and have them sorted correctly?

  • 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-27T20:30:43+00:00Added an answer on May 27, 2026 at 8:30 pm

    You can do

    var sortedItems = myLookupProperty.Items.OrderBy(x => x.WhateverPropertyYouWantToSortOn);
    myLookupProperty.Clear();
    foreach (var item in sortedItems) {
      myLookupProperty.Add(item);
    }
    

    And that will work for you. The reason that the first method you tried didn’t work (as I imagine you guessed) is that it just appends the new item to the bottom. The reason that the second method you proposed didn’t work is that you break the binding when you replace the instance of ObservableCollection that your UI has bound to. It will not properly communicate that the contents are changed after this!

    As a side note, it appears that this exact question was asked here!

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

Sidebar

Related Questions

I have a folder in my WPF app Images that has several .png files
I have a WPF app, my purpose is that the app can be automatically
I've got a simple WPF 4.0 app that currently has no concept of user
I have a simple wpf app which has a button that increments a value
I have a WPF app that has a ListBox . The drag mechanism is
Everyone, I have a WPF app that has a canvas that I have wrapped
Okay, here's my situation. I have a WPF app that I have created that
This is an interesting conundrum. We have a WPF app that has a Vista-like
I have a WPF app that uses a business object called Visit, it has
I have a WPF/MVVM (using MVVM-Light) app setup with a ComboBox that is inside

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.