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

  • Home
  • SEARCH
  • 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 6340563
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T19:51:32+00:00 2026-05-24T19:51:32+00:00

I have a SortableListView of which I set the ItemsSource via a binding. Something

  • 0

I have a SortableListView of which I set the ItemsSource via a binding. Something like the following:

  <SortableListView ItemsSource="{Binding Items}">
    <SortableListView.View>
      <GridView>
        <SortableGridViewColumn
          Header="Name"
          SortProperty="ProductName"
          DisplayMemberBinding="{Binding ProductName}"/>
      </GridView>
    </SortableListView.View>
  </SortableListView>

When the window gets shown I initialize and fill the ObservableCollection<Item> Items.

Now I would like to add one (and only one) special item to the top of the list and always keep this as the first item, regardless of the sort order.

Currently I can think of two possible ways to achieve this:

  1. Create a very special data template for my ListView where I can add the special item and theme the ListView to process everything accordingly.
  2. Bind to the header and handle the click event to perform the sorting in my code-behind file and insert the special item at the top.

Option 1 seems like too much and too complicated work and option 2 is something I would like to avoid.

Are there any alternative solutions to this I am missing? If not, what would be the best option to achieve this, and how should I approach the theme option?

  • 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-24T19:51:32+00:00Added an answer on May 24, 2026 at 7:51 pm

    I’m taking a guess here but I’m assuming you’re using this control?:

    http://thejoyofcode.com/Sortable_ListView_in_WPF.aspx

    If so, it uses the ICollectionView to manage it’s sorting. ICollectionView is very flexible and allows for multiple fields to be sorted (you know like in SQL: SORT BY Field1 ASC, Field2 DESC).

    I think what you want to do is insert an extra sort description before adding the description for the property the user has chosen. That way it will sort by your ‘flagged’ items first, then the chosen property name.

    (code adapted from above article)

    private void Sort(string sortBy, ListSortDirection direction)
    {
        ICollectionView dataView = CollectionViewSource.GetDefaultView(this.ItemsSource);
    
        if (dataView != null)
        {
            dataView.SortDescriptions.Clear();
    
            dataView.SortDescriptions.Add(new SortDescription("IsAtTop", ListSortDirection.Ascending));
            SortDescription sd = new SortDescription(sortBy, direction);
            dataView.SortDescriptions.Add(sd);
            dataView.Refresh();
        }
    }
    

    So you’d just need to add a bool property to your object called ‘IsAtTop’.

    Hopefully this is what you need….

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

Sidebar

Related Questions

Have the following scenario. I have a few form, which essentially have a few
Have a xml data like <Items><Item><name>test1</name></Item><Item><name>test2</name></Item></Items> Looks like jaxb cannot unmashall this when defining
Have following listener for keyboard ArrowDown event(it's key code is 40 ): window.onload =
Have been following Rails Tutorial by Michael Hart rails version 3.0 on mac OS
I have a .NET 2.0 windows forms app, which makes heavy use of the
Have just started using Visual Studio Professional's built-in unit testing features, which as I
Have you managed to get Aptana Studio debugging to work? I tried following this,
Have advancements in CPU design like dynamic instruction scheduling narrowed the performance gap between
Have anyone used Redmine Documentor which lets you convert PHP to HTML to Redmine
have the following text file: <div> <asp:HyperLinkField HeaderText=Hello World of Regular Expression /> </div>

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.