System.Windows.Data.ListCollectionView.Refresh C# (CSharp) Method

Refresh() public method

public Refresh ( ) : void
return void
		public override void Refresh ()
		{
			if (IsAddingNew || IsEditingItem)
				throw new InvalidOperationException ("Cannot refresh while adding or editing an item");

			if (((IDeferRefresh) this).DeferLevel != 0)
				return;

			if (RootGroup == null)
				RootGroup = new StandardCollectionViewGroup (null, null, 0, false, SortDescriptions);

			Groups = null;
			RootGroup.ClearItems ();

			if (ActiveList != SourceCollection) {
				filteredList.Clear ();
				foreach (var item in SourceCollection)
					AddToFiltered (item, false);

				if (SortDescriptions.Count > 0)
					filteredList.Sort (new PropertyComparer (SortDescriptions));

				if (GroupDescriptions.Count > 0 && filteredList.Count > 0) {
					foreach (var item in filteredList)
						RootGroup.AddInSubtree (item, Culture, GroupDescriptions, false);
					Groups = RootGroup.Items;
				}
			}

			IsEmpty = ActiveList.Count == 0;
			int index = IndexOf (CurrentItem);
			if (index < 0 && CurrentPosition != -1 && !IsEmpty)
				index = 0;

			RaiseCollectionChanged (new NotifyCollectionChangedEventArgs (NotifyCollectionChangedAction.Reset));
			MoveCurrentTo (index, true);
		}

Usage Example

 /// <summary>
 /// Initializes a new instance of the <see cref="VisualTreeViewModel"/> class.
 /// </summary>
 public LogicalTreeViewModel()
 {
     _selectedTreeItemService = ServiceLocator.Resolve<SelectedTreeItemService>();
     var treeElementService = ServiceLocator.Resolve<LogicalTreeService>();
     Elements = new ListCollectionView(treeElementService.Elements);
     Elements.CurrentChanged += CurrentElementChanged;
     treeElementService.ElementsChanged += (s, e) => Elements.Refresh();
 }
All Usage Examples Of System.Windows.Data.ListCollectionView::Refresh