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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T16:08:37+00:00 2026-05-24T16:08:37+00:00

I have an observable collection that is exposed to the user by a collectionviewsource.

  • 0

I have an observable collection that is exposed to the user by a collectionviewsource. One of the properties on the items in the collection is sortorder. I am trying to allow the user to permanently resort this collection and propagate the changes to the db.

I have the CVS working where I can resort the individual items as they are displayed in the listbox. Now however I have to change the item.sortorder==cvs.currentindex and i am having trouble figuring out the proper way to do this.

EDIT

evidently I was not clear enough. Sortorder is a field in my DB that is part of my object that allows the user to control position of the items as displayed in list controls. I am trying to give my user the ability to change how these items are sorted in the future by changing the value of the sortorder field to equal the current index of the displayed item.

items current sortorder value is 3.

user moves displayed listitem to position 0(ie first position)

items new sortorder=0 item with original sortorder will become 1 etc

this would be achieved by looping through the sorted CVS and making Item.SortOrder= CVS.Item.index

  • 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-24T16:08:38+00:00Added an answer on May 24, 2026 at 4:08 pm

    I figured it out.

    I went back and looked at the code that I was using to change the position of the elements and I am actually using the collection itself:

    private void OnDecreaseSortOrderCommandExecute()
            {
                int index = QuestionsCVS.View.CurrentPosition;
                QuestionsViewModel item = SelectedQuestionVM;
    
                if (item != null && index > 0)
                {
                    SortableQuestionsVMCollection.RemoveAt(index);
                    SortableQuestionsVMCollection.Insert(index - 1, item);
                    QuestionsCVS.View.Refresh();
                    QuestionsCVS.View.MoveCurrentTo(item);
                }
            }
    

    So I simply did this:

    private void ResortSortableQuestionsVMCollection()
            {
                for (int i = 0; i < SortableQuestionsVMCollection.Count; i++)
                {
                    SortableQuestionsVMCollection[i].SortOrder = i;
                }
            }
    

    I dont know if this will work in every circumstance but it certainly did what I wanted for this one.

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

Sidebar

Related Questions

I have one observable collection with user control. And I am bind it in
I have an observable collection ie Owners and that collection has child items ie
The situation is like this: I have an Observable Collection that has a bunch
I'm stumped here. I have an observable collection that holds business objects. I have
Say I have a ListBox that is bound to an observable collection on my
I have an observable collection bound to a listbox in WPF. One of the
I have my class that has an internal observable collection. I want to pass
I have the following bit of code that modifies an observable collection of 'screens'
I have an method that takes in an observable collection (returned from a webservice)
I have an extension class that is converting an Observable collection to list and

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.