本文整理汇总了C#中System.ComponentModel.SortDescription类的典型用法代码示例。如果您正苦于以下问题:C# SortDescription类的具体用法?C# SortDescription怎么用?C# SortDescription使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SortDescription类属于System.ComponentModel命名空间,在下文中一共展示了SortDescription类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ContactViewModel
public ContactViewModel(BusinessCoreService businessCoreService, ConversationViewModel conversation)
{
_businessCoreService = businessCoreService;
_conversation = conversation;
IsSelected = false;
CvsStaff = new CollectionViewSource { Source = _businessCoreService.GetContacts() };
GroupDescription gp = new PropertyGroupDescription("OrganizationId");
SortDescription sp = new SortDescription("OrganizationId", ListSortDirection.Ascending);
CvsStaff.GroupDescriptions.Add(gp);
CvsStaff.SortDescriptions.Add(sp);
CvsStaff.Filter += ApplyFilter;
var treeSource = _businessCoreService.GetOrganizationTreeNoChildren();
var data = new ObservableCollection<OrganizationTreeInfoViewModel>();
foreach (var item in treeSource)
{
data.Add(new OrganizationTreeInfoViewModel(item, _businessCoreService));
}
var result = GetOrganizationTree(data.Where(x => x.Info.ParentId == null).ToList(), data);
_organizationTreeSource = new ObservableCollection<OrganizationTreeInfoViewModel>(result);
OrganizationTreeCvsStaff = new CollectionViewSource { Source = _organizationTreeSource };
Subscription.DoSelectedTree(SelectedUsersCallback);
}
示例2: Sort
public static void Sort(ItemsControl listView, string sortBy, ListSortDirection direction)
{
listView.Items.SortDescriptions.Clear();
var sd = new SortDescription(sortBy, direction);
listView.Items.SortDescriptions.Add(sd);
listView.Items.Refresh();
}
示例3: Sort
private void Sort(string sortBy, ListSortDirection direction)
{
try
{
ICollectionView dataView = CollectionViewSource.GetDefaultView(listView_log.DataContext);
dataView.SortDescriptions.Clear();
SortDescription sd = new SortDescription(sortBy, direction);
dataView.SortDescriptions.Add(sd);
if (_lastHeaderClicked2 != null)
{
if (String.Compare(sortBy, _lastHeaderClicked2) != 0)
{
SortDescription sd2 = new SortDescription(_lastHeaderClicked2, _lastDirection2);
dataView.SortDescriptions.Add(sd2);
}
}
dataView.Refresh();
Settings.Instance.ResColumnHead = sortBy;
Settings.Instance.ResSortDirection = direction;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace);
}
}
示例4: SetupSyncObjectViewModelsView
private void SetupSyncObjectViewModelsView()
{
this.SyncObjectViewModelsView = new ListCollectionView( this._syncObjectVMs );
var displayNameSorting = new SortDescription( "Model.DisplayName", ListSortDirection.Ascending );
this.SyncObjectViewModelsView.SortDescriptions.Add( displayNameSorting );
this.SyncObjectViewModelsView.Filter = this.SyncObjectViewModelsView_Filter;
}
示例5: PageAirportFacilities
public PageAirportFacilities(AirportMVVM airport)
{
Airport = airport;
DataContext = Airport;
FacilityTypes =
Enum.GetValues(typeof(AirportFacility.FacilityType)).Cast<AirportFacility.FacilityType>().ToList();
if (!airport.Airport.Terminals.AirportTerminals.Exists(t => t.Type == Terminal.TerminalType.Cargo))
FacilityTypes.Remove(AirportFacility.FacilityType.Cargo);
InitializeComponent();
var view = (CollectionView)CollectionViewSource.GetDefaultView(lbFacilities.ItemsSource);
view.SortDescriptions.Clear();
var sortAirlineDescription = new SortDescription(
"Facility.Airline.Profile.Name",
ListSortDirection.Ascending);
view.SortDescriptions.Add(sortAirlineDescription);
var sortFacilityDescription = new SortDescription(
"Facility.Facility.Shortname",
ListSortDirection.Ascending);
view.SortDescriptions.Add(sortFacilityDescription);
}
示例6: SortOrderCombo_OnSelectionChanged
private void SortOrderCombo_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
{
ComboBoxItem cbi = e.AddedItems[0] as ComboBoxItem;
if (cbi != null)
{
string newSortOrder;
if (cbi.Tag == null)
{
newSortOrder = "None";
}
else
{
newSortOrder = cbi.Tag.ToString();
}
SortDescription sortDesc = new SortDescription(newSortOrder, ListSortDirection.Ascending);
ICollectionView cv = CollectionViewSource.GetDefaultView(DataContext);
if (cv != null)
{
cv.SortDescriptions.Clear();
if (newSortOrder != "None")
cv.SortDescriptions.Add(sortDesc);
{
}
}
}
}
示例7: NewUserRegistration
public NewUserRegistration()
{
InitializeComponent();
this.contactsCollection = new System.Windows.Data.CollectionViewSource();
this.contactsCollection.Source = ((NewUserRegistrationViewModel)this.DataContext).RegisteredUsers;
System.ComponentModel.SortDescription contactsSort = new System.ComponentModel.SortDescription("FirstLetter", System.ComponentModel.ListSortDirection.Ascending);
this.contactsCollection.SortDescriptions.Add(contactsSort);
BackgroundWorker worker = new BackgroundWorker();
DispatcherHelper.InvokeOnUiThread(() =>
{
NewUserRegistration.InitializeDictionaries();
RegionInfo region = RegionInfo.CurrentRegion;
this.CountryCodeListPicker.ItemsSource = NewUserRegistration.CountryNameToCode.Keys.ToArray();
if (NewUserRegistration.CountryNameToCode.ContainsKey(region.TwoLetterISORegionName))
{
this.CountryCodeListPicker.SelectedItem = (string)NewUserRegistration.CountryNameToCode[region.TwoLetterISORegionName];
}
else
{
this.CountryCodeListPicker.SelectedItem = (string)NewUserRegistration.CodeToCountry["US"];
}
},
true);
worker.RunWorkerAsync();
}
示例8: RestoreSorting
public static void RestoreSorting(DataGridSortDescription sortDescription, DataGrid grid, ICollectionView view)
{
if (sortDescription.SortDescription != null && sortDescription.SortDescription.Count == 0)
{
if (Core.Settings.Default.CacheListEnableAutomaticSorting)
{
if (Core.Settings.Default.CacheListSortOnColumnIndex >= 0 && Core.Settings.Default.CacheListSortOnColumnIndex < grid.Columns.Count)
{
SortDescription sd = new SortDescription(grid.Columns[Core.Settings.Default.CacheListSortOnColumnIndex].SortMemberPath, Core.Settings.Default.CacheListSortDirection == 0 ? ListSortDirection.Ascending : ListSortDirection.Descending);
sortDescription.SortDescription.Add(sd);
}
}
}
//restore the column sort order
if (sortDescription.SortDescription != null && sortDescription.SortDescription.Count > 0)
{
sortDescription.SortDescription.ToList().ForEach(x => view.SortDescriptions.Add(x));
view.Refresh();
}
//restore the sort directions. Arrows are nice :)
foreach (DataGridColumn c in grid.Columns)
{
if (sortDescription.SortDirection.ContainsKey(c))
{
c.SortDirection = sortDescription.SortDirection[c];
}
}
}
示例9: OrderByLastName
private void OrderByLastName(ListSortDirection dir)
{
ICollectionView dataView = CollectionViewSource.GetDefaultView(testListView.ItemsSource);
dataView.SortDescriptions.Clear();
SortDescription sd = new SortDescription("LastName", dir);
dataView.SortDescriptions.Add(sd);
dataView.Refresh();
}
示例10: Convert
/// <summary>
/// Converts a value.
/// </summary>
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
IList collection = value as System.Collections.IList;
ListCollectionView view = new ListCollectionView(collection);
SortDescription sort = new SortDescription(parameter.ToString(), ListSortDirection.Ascending);
view.SortDescriptions.Add(sort);
return view;
}
示例11: Sort
private void Sort(string sortBy, ListSortDirection direction)
{
ICollectionView dataView = CollectionViewSource.GetDefaultView(TrackList.ItemsSource);
dataView.SortDescriptions.Clear();
SortDescription sd = new SortDescription(sortBy, direction);
dataView.SortDescriptions.Add(sd);
dataView.Refresh();
}
示例12: SetNewSortOrder
private void SetNewSortOrder()
{
string newSortOrder = ((ComboBoxItem)sortOrderCombo.SelectedItem).Content.ToString();
SortDescription sortDesc = new SortDescription(newSortOrder, ListSortDirection.Ascending);
CollectionViewSource src = (CollectionViewSource)FindResource("processesView");
src.SortDescriptions.Clear();
src.SortDescriptions.Add(sortDesc);
}
示例13: PageAirlineServices
public PageAirlineServices(AirlineMVVM airline)
{
this.Classes = new ObservableCollection<AirlineClassMVVM>();
foreach (AirlinerClass.ClassType type in Enum.GetValues(typeof(AirlinerClass.ClassType)))
{
if ((int)type <= GameObject.GetInstance().GameTime.Year)
{
AirlineClassMVVM rClass = new AirlineClassMVVM(type);
foreach (RouteFacility.FacilityType facilityType in Enum.GetValues(typeof(RouteFacility.FacilityType)))
{
if (GameObject.GetInstance().GameTime.Year >= (int)facilityType)
{
AirlineClassFacilityMVVM facility = new AirlineClassFacilityMVVM(facilityType);
facility.Facilities.Clear();
foreach (RouteFacility rFacility in AirlineHelpers.GetRouteFacilities(GameObject.GetInstance().HumanAirline, facilityType))
facility.Facilities.Add(rFacility);
facility.SelectedFacility = RouteFacilities.GetBasicFacility(facility.Type);//GetFacilities(rFacility.Type).OrderBy(f => f.ServiceLevel).First();
rClass.Facilities.Add(facility);
}
}
this.Classes.Add(rClass);
}
}
this.Airline = airline;
this.DataContext = this.Airline;
this.Loaded += PageAirlineServices_Loaded;
InitializeComponent();
CollectionView view = (CollectionView)CollectionViewSource.GetDefaultView(lvFacilities.ItemsSource);
view.GroupDescriptions.Clear();
view.SortDescriptions.Clear();
PropertyGroupDescription groupDescription = new PropertyGroupDescription("Type");
view.GroupDescriptions.Add(groupDescription);
SortDescription sortTypeDescription = new SortDescription("Type", ListSortDirection.Ascending);
view.SortDescriptions.Add(sortTypeDescription);
SortDescription sortFacilityDescription = new SortDescription("Facility.Name", ListSortDirection.Ascending);
view.SortDescriptions.Add(sortFacilityDescription);
for (int i = 120; i < 300; i += 15)
cbCancellationPolicy.Items.Add(i);
cbCancellationPolicy.SelectedItem = this.Airline.Airline.getAirlinePolicy("Cancellation Minutes").PolicyValue;
}
示例14: SortList
/// <summary>
/// Sort the data.
/// </summary>
private void SortList(string propertyName)
{
// Get the data to sort.
ICollectionView dataView = CollectionViewSource.GetDefaultView(this.ItemsSource);
// Specify the new sorting information.
dataView.SortDescriptions.Clear();
SortDescription description = new SortDescription(propertyName, sortDirection);
dataView.SortDescriptions.Add(description);
dataView.Refresh();
}
示例15: LogitemsViewHeaderClicked
private void LogitemsViewHeaderClicked(object sender, RoutedEventArgs e)
{
var header = e.OriginalSource as GridViewColumnHeader;
if (null == header) { return; }
var source = (ListView)e.Source;
var nameOfHeader = header.Content.ToString();
var dataView = CollectionViewSource.GetDefaultView(source.ItemsSource);
dataView.SortDescriptions.Clear();
_direction = _direction == ListSortDirection.Ascending ? ListSortDirection.Descending : ListSortDirection.Ascending;
var description = new SortDescription(nameOfHeader, _direction);
dataView.SortDescriptions.Add(description);
dataView.Refresh();
}