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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T17:40:17+00:00 2026-05-13T17:40:17+00:00

myListBox.Items.SortDescriptions.Add( new SortDescription(BoolProperty, ListSortDirection.Descending)); This sorting works only for string properties of the underlying

  • 0

myListBox.Items.SortDescriptions.Add(
new SortDescription(“BoolProperty”, ListSortDirection.Descending));

This sorting works only for string properties of the underlying project. Not with boolean? Is there a reason for that ?

Thanks !

UPDATE:

Yep, your example really works. But what’s wrong on my example ?

public class A
{
    public bool Prop;            
}

List<A> l = new List<A>() {
    new A() { Prop = true  }, 
    new A() { Prop = false }, 
    new A() { Prop = true  },
};

ICollectionView icw = CollectionViewSource.GetDefaultView(l);                                                
icw.SortDescriptions.Add(new SortDescription("Prop", ListSortDirection.Ascending));                
icw.Refresh();
  • 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-13T17:40:18+00:00Added an answer on May 13, 2026 at 5:40 pm

    Hmm, I can seem to add a SortDescription on a boolean property in my list example!

    <Window x:Class="WpfApplication3.Window1"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Window1" Height="300" Width="300">
        <Grid>
            <ListBox x:Name="box" DisplayMemberPath="Test" />
        </Grid>
    </Window>
    

    Code behind:

    public partial class Window1 : Window
    {
        public Window1()
        {
            InitializeComponent();
    
            //4 instances, each with a property Test of another boolean value
            box.ItemsSource = new[] {
                new {Test = true}, 
                new {Test = false}, 
                new {Test = false}, 
                new {Test = true}
            };
    
            box.Items.SortDescriptions.Add(new SortDescription("Test", ListSortDirection.Descending));
        }
    }
    
    
    public class BooleanHolder
    {
        public bool Test { get; set; }
    }
    

    Works like a charm 😉

    Perhaps you misspelled the property name in the SortDescription object? Hope this helps

    In your example you defined Prop as a field. Make it a property and it will work 😉

    public class A
    {
        public bool Prop { get; set; }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am adding items to a ListBox like so: myListBox.Items.addRange(myObjectArray); and I also want
Big question update before continue: Is Items.SortDescription getting fired INotifyPropertyChanged events? From the code
I have a list of items of type ViewLookupItem which has these properties: For
I am having trouble getting my listbox items to stretch to the whole listbox
I click on items in my listbox and then hit a submit button, but
This is how looks my listbox: <ListBox x:Name=ForthListBox Margin=0,0,-12,0 ItemsSource={Binding Tops} Tap=ForthListBox_Tap Style={StaticResource TopListBoxStyle}>
I have a Car class with various properties. I have a static Cars collection
I have Window that has a ListBox ListBox(MyListBox) has a DataTable for its DataContext
I've got this nifty little piece of code here that self-propogates ad infinitum every
I have a ListBox ( MyListBox ) on my screen, and a Textbox (

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.