protected void OnItemsRealized(ItemsRealizedEventArgs e) { var handler = ItemsRealized; if (handler != null) { handler(this, e); } }
private void HandleItemsRealized(object sender, ItemsRealizedEventArgs e) { var viewableDocument = Documents[e.StartingIndex].Item; // collection may have been reset (and hence the item cleared) since the event was raised, thus the null check if (viewableDocument != null) DocumentsHaveId = !string.IsNullOrEmpty(viewableDocument.Id); // When a view is refreshed, items can be realized in different orders (depending on the order the query responses come back from the db) // So to stabilise the column set, we keep a list of 60 most recently used documents, and then sort them in index order. mostRecentDocuments.AddRange(Enumerable.Range(e.StartingIndex, e.Count).Select(i => Documents[i])); if (Columns.Source == ColumnsSource.Automatic) { var newColumns = GetCurrentColumnsSuggestion(); if (!Columns.Columns.Select(c => c.Binding).SequenceEqual(newColumns.Select(c => c.Binding))) Columns.LoadFromColumnDefinitions(newColumns); } }