Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
460
Sorting a databound collection
posted

I have my colleciton of header/children data in an observablecollection that is bound to the outlook bar.  How do I sort the listbox that is in each outlookbar area ?

Parents
No Data
Reply
  • 69686
    posted

    Hello,

     A solution to this problem is to presort the data before binding it to the XamOutlookBar. Another way is to add a button in the XamOutlookBar and handle its click event. A quick way to sort the observable collection is like this:

    private void buttonSort_Click(object sender, RoutedEventArgs e)
            {

                List<int> temp = observableCollection.ToList();
                observableCollection.Clear();
                temp.Sort();
                foreach (int item in temp)
                {
                    observableCollection.Add(item);
                }
                listView.ItemsSource = observableCollection;

            } 

    Hope this helps 

Children
No Data