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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T05:17:45+00:00 2026-05-18T05:17:45+00:00

I’m using C# WPF following the MVVM design pattern. Currently my View has a

  • 0

I’m using C# WPF following the MVVM design pattern. Currently my View has a ListView which contains several columns and rows ( i.e. ListViewItems ).

The ViewModel exposes an ObservableCollection<Person> collection ( as shown below ) which the View binds to.

public ObservableCollection<Person> People
{
    get
    {
        return _people;
    }
    set
    {
        // new value?
        if( value != _people )
        {
            // Set
            _people = value;

            // Notify
            OnPropertyChanged( "People" );
        }
    }
}

and here is the binding snippet

<ListView ItemsSource="{Binding People}" ... >
    <!-- Omitted -->
</ListView>

In the View the user may click on a column header and the ListView will sort itself accordingly. The problem is that some of the logic and commands in the ViewModel are sensitive to the order of elements and when the ListView is sorted on a particular column the underlying People collection in the ViewModel doesn’t reflect the order the user is seeing.

Any clue on how to synchronize the sorted ListViewItems in the ListView with the underlying ObservableCollection<Person>?

Edit Already tried Mode=TwoWay on the ListView ItemsSource, that didn’t work.

  • 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-18T05:17:45+00:00Added an answer on May 18, 2026 at 5:17 am

    The problem is (as you yourself stated) that some of the logic and commands in the ViewModel are sensitive to the order of elements. In short, they shouldn’t be; if the reason is actually reordering the items (just about the only one I can imagine where the order would be important), then the view shouldn’t be sortable by columns. Otherwise you need to find ways to make the order irrelevant – perhaps you could give an example of an action that depends on the order of items? That way we could suggest a real solution.

    Also wanted to clarify that the order of the items in the view has no relation to their order in the source ObservableCollection. Generally the ItemsControls automatically create an ICollectionView that is sorted independently. Edit: yeah well not an actual ICollectionView, it’s a more complicated mechanism (what the ItemCollection does in conjunction with the ItemContainerGenerator) but you get the picture.

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

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I am reading a book about Javascript and jQuery and using one of the

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.