public void DataGridMengeOptimationScritSortNaacZait() { var SortOrder = System.ComponentModel.ListSortDirection.Descending; var SortDescriptionZiilProcessLeseBeginZait = new System.ComponentModel.SortDescription( DataGridMengeOptimationScritWirkungColumnZiilProcessLeeseBeginZaitKalender.SortMemberPath, SortOrder); var ListeSortDescription = new System.ComponentModel.SortDescription[] { SortDescriptionZiilProcessLeseBeginZait }; foreach (var Column in DataGridMengeOptimationScrit.Columns) { Column.SortDirection = null; } DataGridMengeOptimationScritWirkungColumnZiilProcessLeeseBeginZaitKalender.SortDirection = SortOrder; DataGridMengeOptimationScrit.Items.SortDescriptions.Clear(); foreach (var SortDescription in ListeSortDescription) { DataGridMengeOptimationScrit.Items.SortDescriptions.Add(SortDescription); } }
/// <summary> /// Creates an instance of YapperChatView. This is the main page for /// YapperChat. The pivot view displays the chats and the contacts /// registered with Yapper /// </summary> public YapperChatMessagesPivot() { InitializeComponent(); Messenger.Default.Send <SuspendTaskCountEvent>(new SuspendTaskCountEvent() { Suspend = true }); YapperChatViewModel viewModel = new YapperChatViewModel(true); this.DataContext = viewModel; // subscribe to push notifications PushNotification.PushNotification.Instance.Setup(); // CollectionViewSource is used so that the list of conversations is maintained in the // sorted order. this.FavoritesCollection = new System.Windows.Data.CollectionViewSource(); this.FavoritesCollection.Source = viewModel.AllConversations.Conversations; System.ComponentModel.SortDescription favoritesSort = new System.ComponentModel.SortDescription("LastPostUtcTime", System.ComponentModel.ListSortDirection.Descending); this.FavoritesCollection.SortDescriptions.Add(favoritesSort); this.FavoritesListBox.ItemsSource = this.FavoritesCollection.View; BuildLocalizedApplicationBar(); }
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { System.Collections.ObjectModel.ObservableCollection <StaffIncentiveLineHelperObject> collection = value as System.Collections.ObjectModel.ObservableCollection <StaffIncentiveLineHelperObject>; ListCollectionView view = new ListCollectionView(collection); System.ComponentModel.SortDescription sort = new System.ComponentModel.SortDescription(parameter.ToString(), System.ComponentModel.ListSortDirection.Ascending); view.SortDescriptions.Add(sort); return(view); }
void sort(string sortby, System.ComponentModel.ListSortDirection listSortDirection) { System.ComponentModel.ICollectionView dataView = CollectionViewSource.GetDefaultView(dataGrid.ItemsSource); if (dataView != null) { dataView.SortDescriptions.Clear(); System.ComponentModel.SortDescription sd = new System.ComponentModel.SortDescription(sortby, listSortDirection); dataView.SortDescriptions.Add(sd); dataView.Refresh(); } }
private void filterRules() { LogHelper.Debug("Filtering rules..."); try { Predicate <WFPRules::Rule> pred = null; switch (TypeFilter) { case TypeFilterEnum.ACTIVE: pred += activeRulesPredicate; break; case TypeFilterEnum.WFN: pred += WFNRulesPredicate; break; case TypeFilterEnum.WSH: pred += WSHRulesPredicate; break; case TypeFilterEnum.ALL: default: break; } if (Filter.Length > 0) { pred += filteredRulesPredicate; // text filter } //This code is messy, but the WPF DataGrid forgets the sorting when you change the ItemsSource, and you have to restore it in TWO places. System.ComponentModel.SortDescription oldSorting = gridRules.Items.SortDescriptions.FirstOrDefault(); String oldSortingPropertyName = oldSorting.PropertyName ?? gridRules.Columns.FirstOrDefault().Header.ToString(); System.ComponentModel.ListSortDirection oldSortingDirection = oldSorting.Direction; gridRules.ItemsSource = (pred is null ? allRules : allRules.Where(r => pred.GetInvocationList().All(p => ((Predicate <WFPRules::Rule>)p)(r)))).ToList(); gridRules.Items.SortDescriptions.Add(new System.ComponentModel.SortDescription(oldSortingPropertyName, oldSortingDirection)); foreach (var column in gridRules.Columns) { if (column.Header.ToString() == oldSortingPropertyName) { column.SortDirection = oldSortingDirection; } } gridRules.Items.Refresh(); } catch (Exception e) { LogHelper.Error("Unable to filter FW rules", e); } }
// Exercise 1: Inventory List - sort columns private void GridViewColumnHeader_Click(object sender, RoutedEventArgs e) { GridViewColumnHeader column = (sender as GridViewColumnHeader); // Grab the Tag from the column header string sortBy = column.Tag.ToString(); // Clear out any previous column sorting uxInventoryList.Items.SortDescriptions.Clear(); // sort the uxInventoryList by the column header tag (sortBy) // if you want to do Descending, look at the homework :) and SortAdorner var sortDescription = new System.ComponentModel.SortDescription(sortBy, System.ComponentModel.ListSortDirection.Ascending); uxInventoryList.Items.SortDescriptions.Add(sortDescription); }
public YapperChatContactsPivot() { InitializeComponent(); YapperChatViewModel viewModel = new YapperChatViewModel(false); this.DataContext = viewModel; this.contactsCollection = new System.Windows.Data.CollectionViewSource(); this.contactsCollection.Source = viewModel.RegisteredUsers.RegisteredUsers; System.ComponentModel.SortDescription contactsSort = new System.ComponentModel.SortDescription("FirstLetter", System.ComponentModel.ListSortDirection.Ascending); this.contactsCollection.SortDescriptions.Add(contactsSort); this.ContactsListSelector.ItemsSource = viewModel.RegisteredUsers.RegisteredUsers; this.groupsCollection = new System.Windows.Data.CollectionViewSource(); this.groupsCollection.Source = viewModel.Groups.Groups; System.ComponentModel.SortDescription groupsSort = new System.ComponentModel.SortDescription("Name", System.ComponentModel.ListSortDirection.Ascending); this.contactsCollection.SortDescriptions.Add(groupsSort); BuildLocalizedApplicationBar(); }
private void btRefresh_Click(object sender, RoutedEventArgs e) { System.ComponentModel.SortDescription sd = new System.ComponentModel.SortDescription(); cbAlignment.Items.SortDescriptions.Add(sd); cbSurfEx.Items.SortDescriptions.Add(sd); cbSurfPr.Items.SortDescriptions.Add(sd); }
private void btRefresh_Click(object sender, RoutedEventArgs e) { try { cbLayerUse.Items.Clear(); foreach (var item in AcadApp.GetLayersList()) { cbLayerUse.Items.Add(item as object); cbLayerUse.Text = cbLayerUse.Items[0] as String; } System.ComponentModel.SortDescription sd = new System.ComponentModel.SortDescription(); cbLayerUse.Items.SortDescriptions.Add(sd); cbLinetUse.Items.Clear(); foreach (var item in AcadApp.GetLinetypeList()) { cbLinetUse.Items.Add(item as object); cbLinetUse.Text = cbLinetUse.Items[0] as String; } cbLinetUse.Items.SortDescriptions.Add(sd); } catch (Exception ex) { AcadApp.AcaEd.WriteMessage("\nERROR: AreaLinearCalc.btRefresh_Click() " + ex + "\n"); } }
async protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e) { if (this.DataContext == null) { Guid conversationId; string senderName = null; base.OnNavigatedTo(e); conversationId = Guid.Parse(NavigationContext.QueryString["conversationId"]); if (NavigationContext.QueryString.ContainsKey("recipientName")) { senderName = NavigationContext.QueryString["recipientName"]; } Guid messageId = Guid.Empty; if (NavigationContext.QueryString.ContainsKey("messageId")) { messageId = Guid.Parse(NavigationContext.QueryString["messageId"]); } int recipient = -1; if (NavigationContext.QueryString.ContainsKey("recipientId")) { recipient = Int32.Parse(NavigationContext.QueryString["recipientId"]); } bool?isGroup = null; if (NavigationContext.QueryString.ContainsKey("isGroup")) { isGroup = Boolean.Parse(NavigationContext.QueryString["isGroup"]); } int pivot = 0; if (NavigationContext.QueryString.ContainsKey("pivot")) { pivot = Int32.Parse(NavigationContext.QueryString["pivot"]); } if (messageId != Guid.Empty) { //DataSync.Instance.SyncMessageId(conversationId, messageId); } // Before the messages are loaded, ensure that the scroll handler is set correctly. var scrollToEndHandler = new System.Collections.Specialized.NotifyCollectionChangedEventHandler( (s1, e1) => { if (this.messagesListBox.ItemsSource.Count > 0) { this.messagesListBox.UpdateLayout(); object lastItem = this.messagesListBox.ItemsSource[this.messagesListBox.ItemsSource.Count - 1]; this.messagesListBox.ScrollTo(lastItem); } }); //INotifyCollectionChanged listItems = this.messagesListBox.ItemsSource as INotifyCollectionChanged; //listItems.CollectionChanged += scrollToEndHandler; UserModel recipientUser = DataSync.Instance.GetUser(recipient); if (recipientUser == null) { UserType userType = isGroup.HasValue && isGroup.Value ? UserType.Group : UserType.User; recipientUser = new Models.UserModel() { Id = recipient, Name = senderName, UserType = userType }; } // Create the viewmodel and load the messages ConversationMessagesViewModel cvm = new ConversationMessagesViewModel(conversationId, recipientUser, isGroup); this.DataContext = cvm; cvm.LoadMessagesForConversations(); if (cvm.IsGroup && cvm.Recipient != null && !cvm.Recipient.IsGroupMember) { MessageBox.Show(Strings.NotAGroupMember); } // Bind the list items to a collection view source // This helps in sorting the messages based on post time // without having to maintain the list in the view model in a sorted order CollectionViewSource messageCollection = new CollectionViewSource(); messageCollection.Source = ((ConversationMessagesViewModel)this.DataContext).Messages; System.ComponentModel.SortDescription sort = new System.ComponentModel.SortDescription("PostDateTime", System.ComponentModel.ListSortDirection.Ascending); messageCollection.SortDescriptions.Add(sort); messagesListBox.ItemsSource = ((ConversationMessagesViewModel)this.DataContext).Messages; this.ConversationPagePivot.SelectedIndex = pivot; (Application.Current as App).watcher.PositionChanged += watcher_PositionChanged; (Application.Current as App).watcher.StatusChanged += watcher_StatusChanged; (Application.Current as App).Currentlocation = await(Application.Current as App).watcher.GetGeopositionAsync(); } }
private void GetHomeTimeline() { var timelineResult = TwitterTimeline.HomeTimeline(tokens, new TimelineOptions() { Count = FirstGetCount }); if (timelineResult.Result != RequestResult.Success) { MessageBox.Show("Failed getting your home timeline. This application will be shutdown." + Environment.NewLine + "Result: " + timelineResult.Result.ToString() + Environment.NewLine + "Error message:" + Environment.NewLine + timelineResult.ErrorMessage, "Getting timeline error", MessageBoxButton.OK, MessageBoxImage.Error); Application.Current.Shutdown(); return; } timeline = new ObservableCollection<TwitterStatus>(timelineResult.ResponseObject); this.Dispatcher.BeginInvoke(new Action(() => { CollectionViewSource cvs = new CollectionViewSource(); var sd = new System.ComponentModel.SortDescription(); sd.Direction = System.ComponentModel.ListSortDirection.Descending; sd.PropertyName = "CreatedDate"; cvs.SortDescriptions.Add(sd); cvs.Source = timeline; timeLineView.ItemsSource = cvs.View; }), null); }