- ObservableCollectionSortingExample.zip
- ObservableCollectionSortingExample
- Local.testsettings
- ObservableCollectionSortingExample.Model
- ObservableCollectionSortingExample.sln
- ObservableCollectionSortingExample.suo
- ObservableCollectionSortingExample.Test
- ObservableCollectionSortingExample.vsmdi
- ObservableCollectionSortingExample
- TestResults
- michael_MICHAEL-LAPTOP 2011-03-13 18_53_15.trx
- michael_MICHAEL-LAPTOP 2011-03-13 18_53_44.trx
- michael_MICHAEL-LAPTOP 2011-03-13 18_54_33.trx
- michael_MICHAEL-LAPTOP 2011-03-13 18_56_10.trx
- michael_MICHAEL-LAPTOP 2011-03-13 18_56_49.trx
- michael_MICHAEL-LAPTOP 2011-03-13 18_59_24.trx
- michael_MICHAEL-LAPTOP 2011-03-13 19_00_20.trx
- michael_MICHAEL-LAPTOP 2011-03-13 19_03_13.trx
- michael_MICHAEL-LAPTOP 2011-03-13 19_16_27.trx
- michael_MICHAEL-LAPTOP 2011-03-13 19_16_56.trx
- michael_MICHAEL-LAPTOP 2011-03-13 19_18_03.trx
- michael_MICHAEL-LAPTOP 2011-03-13 19_20_32.trx
- michael_MICHAEL-LAPTOP 2011-03-13 19_20_32
- In
- MICHAEL-LAPTOP
- Out
- AgentRestart.dat
- michael_MICHAEL-LAPTOP 2011-03-13 19_22_58.trx
- michael_MICHAEL-LAPTOP 2011-03-13 19_32_17.trx
- michael_MICHAEL-LAPTOP 2011-03-13 19_33_10.trx
- michael_MICHAEL-LAPTOP 2011-03-13 19_34_31.trx
- michael_MICHAEL-LAPTOP 2011-03-13 19_35_27.trx
- michael_MICHAEL-LAPTOP 2011-03-13 19_37_22.trx
- michael_MICHAEL-LAPTOP 2011-03-13 19_39_21.trx
- michael_MICHAEL-LAPTOP 2011-03-13 19_39_44.trx
- michael_MICHAEL-LAPTOP 2011-03-13 19_40_09.trx
- michael_MICHAEL-LAPTOP 2011-03-13 19_46_15.trx
- michael_MICHAEL-LAPTOP 2011-03-13 19_47_03.trx
- michael_MICHAEL-LAPTOP 2011-03-13 19_49_01.trx
- michael_MICHAEL-LAPTOP 2011-03-14 00_14_01.trx
- TraceAndTestImpact.testsettings
|
using System.ComponentModel;
using System.Windows.Data;
using System.Windows.Input;
namespace ObservableCollectionSortingExample
{
public class PeopleVewModel
{
public PeopleVewModel()
{
People people = new People();
Person person = new Person() { Firstname = "Michael", Lastname = "Bookatz" };
people.Add(person);
person = new Person() { Firstname = "Chris", Lastname = "Johnson" };
people.Add(person);
person = new Person() { Firstname = "John", Lastname = "Doe" };
people.Add(person);
person = new Person() { Firstname = "Ann", Lastname = "Other" };
people.Add(person);
person = new Person() { Firstname = "Jack", Lastname = "Smith" };
people.Add(person);
person = new Person() { Firstname = "Charles", Lastname = "Langford" };
people.Add(person);
this.People = people;
}
People observerablePeople = new People();
private bool sortAscending = true;
public People People
{
private get
{
return this.observerablePeople;
}
set
{
this.observerablePeople = value;
peopleView = new CollectionViewSource();
peopleView.Source = this.observerablePeople;
}
}
CollectionViewSource peopleView;
public ListCollectionView PeopleView
{
get
{
return (ListCollectionView) peopleView.View;
}
}
private CommandStub sortList;
public ICommand SortList
{
get
{
if (sortList == null)
{
sortList = new CommandStub();
sortList.OnExecuting += new CommandStub.ExecutingEventHandler(sortList_OnExecuting);
}
return sortList;
}
}
void sortList_OnExecuting(object parameter)
{
string sortColumn = (string)parameter;
this.peopleView.SortDescriptions.Clear();
if (this.sortAscending)
{
this.peopleView.SortDescriptions.Add(new SortDescription(sortColumn, ListSortDirection.Ascending));
this.sortAscending = false;
}
else
{
this.peopleView.SortDescriptions.Add(new SortDescription(sortColumn, ListSortDirection.Descending));
this.sortAscending = true;
}
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Software Engineer who started coding when I was 5. Core focus is to meet clients real business needs through initial consultation, followed by a communicative and collaborative approach. Delivers applications using C# .net and MS SQL Server. Comfortable working independently, in a team, or mentoring to meets deadlines irrelevant of pressure.
Currently interested in cloud computing with a focus on Microsoft Azure