@ -22,6 +22,7 @@ using System.Collections.Specialized;
using System.ComponentModel ;
using System.ComponentModel ;
using System.Diagnostics ;
using System.Diagnostics ;
using System.Globalization ;
using System.Globalization ;
using System.Linq ;
using System.Threading ;
using System.Threading ;
using System.Windows.Data ;
using System.Windows.Data ;
using Xceed.Utils.Collections ;
using Xceed.Utils.Collections ;
@ -972,44 +973,29 @@ namespace Xceed.Wpf.DataGrid
m_lastAddCount = newSourceItemCount ;
m_lastAddCount = newSourceItemCount ;
m_lastAddIndex = startIndex ;
m_lastAddIndex = startIndex ;
int count = items . Count ;
var filteredItemsChanged = false ;
List < RawItem > filteredItems = new List < RawItem > ( count ) ;
RawItem [ ] rawItems = new RawItem [ count ] ;
for ( int i = 0 ; i < c ount; i + + )
for ( int i = 0 ; i < items . Count ; i + + )
{
{
object item = items [ i ] ;
var index = startIndex + i ;
RawItem rawItem = new RawItem ( startIndex + i , item ) ;
var item = items [ i ] ;
rawItems [ i ] = rawItem ;
var rawItem = new RawItem ( index , item ) ;
if ( this . PassesFilter ( rawItem . DataItem )
if ( this . PassesFilter ( item ) & & this . PassesAutoFilter ( item , null ) & & this . PassesFilterCriterion ( item ) )
& & this . PassesAutoFilter ( rawItem . DataItem , null )
& & this . PassesFilterCriterion ( rawItem . DataItem ) )
{
{
filteredItems . Add ( rawItem ) ;
filteredItemsChanged = true ;
}
}
bool isLast = ( startIndex = = this . SourceItemCount ) ;
this . AddRawItemInSourceList ( startIndex , rawItems ) ;
if ( filteredItems . Count ! = 0 )
this . AddRawItemInSourceList ( index , rawItem ) ;
{
this . AddRawItemInFilteredList ( rawItem ) ;
this . AddRawItemInFilteredList ( filteredItems , isLast ) ;
this . AddRawItemInGroup ( rawItem ) ;
this . AddRawItemInGroup ( filteredItems ) ;
}
else
if ( m_statFunctions . Count > 0 )
{
{
DeferredOperationManager deferredOperationManager = this . DeferredOperationManager ;
this . AddRawItemInSourceList ( index , rawItem ) ;
foreach ( RawItem rawItem in filteredItems )
{
//When adding a new item, make sure all stats for the specified group are recalculated even if UpdateChangedPropertyStatsOnly is set to true
deferredOperationManager . InvalidateGroupStats ( rawItem . ParentGroup , true ) ;
}
}
}
}
}
this . RefreshDistinctValues ( filteredItems . Count > 0 ) ;
this . RefreshDistinctValues ( filteredItemsChanged ) ;
return true ;
return true ;
}
}
@ -1023,38 +1009,31 @@ namespace Xceed.Wpf.DataGrid
return false ;
return false ;
}
}
RawItem rawItem ;
var filteredItemsChanged = false ;
RawItem [ ] removedItems = new RawItem [ count ] ;
for ( int i = 0 ; i < count ; i + + )
for ( int i = 0 ; i < count ; i + + )
{
{
rawItem = m_sourceItemList [ i + startIndex ] ;
var rawItem = m_sourceItemList [ startIndex ] ;
if ( this . CurrentEditItem = = rawItem . DataItem )
if ( this . CurrentEditItem = = rawItem . DataItem )
{
{
this . SetCurrentEditItem ( null ) ;
this . SetCurrentEditItem ( null ) ;
}
}
removedItems [ i ] = rawItem ;
if ( this . RemoveRawItemInFilteredList ( rawItem ) )
{
filteredItemsChanged = true ;
//When removing an item, make sure all stats for the specified group are recalculated even if UpdateChangedPropertyStatsOnly is set to true
this . RemoveRawItemInSourceList ( startIndex ) ;
if ( m_statFunctions . Count > 0 )
this . RemoveRawItemInGroup ( rawItem ) ;
}
else
{
{
this . DeferredOperationManager . InvalidateGroupStats ( rawItem . ParentGroup , true ) ;
this . RemoveRawItemInSourceList ( startIndex ) ;
}
}
}
}
int filteredItemRemovedCount = this . RemoveRawItemInFilteredList ( removedItems ) ;
this . RefreshDistinctValues ( filteredItemsChanged ) ;
// We do the raw item list after cleaning up the filtered list to delay the resequencing of the RawItem.
this . RemoveRawItemInSourceList ( startIndex , count ) ;
if ( filteredItemRemovedCount > 0 )
{
this . RemoveRawItemInGroup ( removedItems ) ;
}
this . RefreshDistinctValues ( filteredItemRemovedCount > 0 ) ;
return true ;
return true ;
}
}
@ -1313,17 +1292,14 @@ namespace Xceed.Wpf.DataGrid
{
{
Debug . Assert ( rawItem . GetGlobalSortedIndex ( ) = = globalSortedIndex ) ;
Debug . Assert ( rawItem . GetGlobalSortedIndex ( ) = = globalSortedIndex ) ;
object dataItem = rawItem . DataItem ;
var dataItem = rawItem . DataItem ;
if ( this . PassesFilter ( dataItem )
if ( this . PassesFilter ( dataItem ) & & this . PassesAutoFilter ( dataItem , null ) & & this . PassesFilterCriterion ( dataItem ) )
& & this . PassesAutoFilter ( dataItem , null )
& & this . PassesFilterCriterion ( dataItem ) )
{
{
if ( globalSortedIndex = = - 1 )
if ( globalSortedIndex = = - 1 )
{
{
RawItem [ ] rawItems = new RawItem [ ] { rawItem } ;
this . AddRawItemInFilteredList ( rawItem ) ;
this . AddRawItemInFilteredList ( rawItems , false ) ;
this . AddRawItemInGroup ( rawItem ) ;
this . AddRawItemInGroup ( rawItems ) ;
this . RefreshDistinctValues ( true ) ;
this . RefreshDistinctValues ( true ) ;
return ;
return ;
@ -1337,9 +1313,8 @@ namespace Xceed.Wpf.DataGrid
{
{
if ( globalSortedIndex ! = - 1 )
if ( globalSortedIndex ! = - 1 )
{
{
RawItem [ ] rawItems = new RawItem [ ] { rawItem } ;
this . RemoveRawItemInFilteredList ( rawItem ) ;
this . RemoveRawItemInFilteredList ( rawItems ) ;
this . RemoveRawItemInGroup ( rawItem ) ;
this . RemoveRawItemInGroup ( rawItems ) ;
}
}
this . RefreshDistinctValues ( true ) ;
this . RefreshDistinctValues ( true ) ;
@ -1347,8 +1322,8 @@ namespace Xceed.Wpf.DataGrid
}
}
// Verify the row is in the correct group.
// Verify the row is in the correct group.
DataGridCollectionViewGroup newGroup = this . GetRawItemNewGroup ( rawItem ) ;
var newGroup = this . GetRawItemNewGroup ( rawItem ) ;
DataGridCollectionViewGroup currentGroup = rawItem . ParentGroup ;
var currentGroup = rawItem . ParentGroup ;
if ( currentGroup ! = newGroup )
if ( currentGroup ! = newGroup )
{
{
@ -1356,14 +1331,14 @@ namespace Xceed.Wpf.DataGrid
{
{
if ( m_statFunctions . Count > 0 )
if ( m_statFunctions . Count > 0 )
{
{
DeferredOperationManage r deferredOperationManager = this . DeferredOperationManager ;
va r deferredOperationManager = this . DeferredOperationManager ;
//If an item is moved from one group to another, make sure all stats for the specified groups are recalculated even if UpdateChangedPropertyStatsOnly is set to true
//If an item is moved from one group to another, make sure all stats for the specified groups are recalculated even if UpdateChangedPropertyStatsOnly is set to true
deferredOperationManager . InvalidateGroupStats ( currentGroup , true ) ;
deferredOperationManager . InvalidateGroupStats ( currentGroup , true ) ;
deferredOperationManager . InvalidateGroupStats ( newGroup , true ) ;
deferredOperationManager . InvalidateGroupStats ( newGroup , true ) ;
}
}
int newSortIndex = newGroup . BinarySearchRawItem ( rawItem , this . RawItemSortComparer ) ;
var newSortIndex = newGroup . BinarySearchRawItem ( rawItem , this . RawItemSortComparer ) ;
if ( newSortIndex < 0 )
if ( newSortIndex < 0 )
{
{
@ -1372,7 +1347,7 @@ namespace Xceed.Wpf.DataGrid
currentGroup . RemoveRawItemAt ( rawItem . SortedIndex ) ;
currentGroup . RemoveRawItemAt ( rawItem . SortedIndex ) ;
newGroup . InsertRawItem ( newSortIndex , rawItem ) ;
newGroup . InsertRawItem ( newSortIndex , rawItem ) ;
int newGlobalSortedIndex = rawItem . GetGlobalSortedIndex ( ) ;
var newGlobalSortedIndex = rawItem . GetGlobalSortedIndex ( ) ;
this . AdjustCurrencyAfterMove ( globalSortedIndex , newGlobalSortedIndex , 1 ) ;
this . AdjustCurrencyAfterMove ( globalSortedIndex , newGlobalSortedIndex , 1 ) ;
this . OnCollectionChanged ( new NotifyCollectionChangedEventArgs ( NotifyCollectionChangedAction . Move , rawItem . DataItem , newGlobalSortedIndex , globalSortedIndex ) ) ;
this . OnCollectionChanged ( new NotifyCollectionChangedEventArgs ( NotifyCollectionChangedAction . Move , rawItem . DataItem , newGlobalSortedIndex , globalSortedIndex ) ) ;
}
}
@ -1403,7 +1378,7 @@ namespace Xceed.Wpf.DataGrid
using ( this . DeferCurrencyEvent ( ) )
using ( this . DeferCurrencyEvent ( ) )
{
{
newGroup . MoveRawItem ( rawItem . SortedIndex , newSortIndex ) ;
newGroup . MoveRawItem ( rawItem . SortedIndex , newSortIndex ) ;
int newGlobalSortedIndex = rawItem . GetGlobalSortedIndex ( ) ;
var newGlobalSortedIndex = rawItem . GetGlobalSortedIndex ( ) ;
this . AdjustCurrencyAfterMove ( globalSortedIndex , newGlobalSortedIndex , 1 ) ;
this . AdjustCurrencyAfterMove ( globalSortedIndex , newGlobalSortedIndex , 1 ) ;
this . OnCollectionChanged ( new NotifyCollectionChangedEventArgs ( NotifyCollectionChangedAction . Move , rawItem . DataItem , newGlobalSortedIndex , globalSortedIndex ) ) ;
this . OnCollectionChanged ( new NotifyCollectionChangedEventArgs ( NotifyCollectionChangedAction . Move , rawItem . DataItem , newGlobalSortedIndex , globalSortedIndex ) ) ;
}
}
@ -1680,7 +1655,7 @@ namespace Xceed.Wpf.DataGrid
private bool MoveSourceItem ( int oldStartIndex , IList items , int newStartIndex )
private bool MoveSourceItem ( int oldStartIndex , IList items , int newStartIndex )
{
{
int count = items . Count ;
var count = items . Count ;
if ( ( oldStartIndex < 0 ) | | ( oldStartIndex + count > m_sourceItemList . Count ) | | ( newStartIndex < 0 ) | | ( newStartIndex > ( m_sourceItemList . Count - count ) ) )
if ( ( oldStartIndex < 0 ) | | ( oldStartIndex + count > m_sourceItemList . Count ) | | ( newStartIndex < 0 ) | | ( newStartIndex > ( m_sourceItemList . Count - count ) ) )
{
{
@ -1688,47 +1663,60 @@ namespace Xceed.Wpf.DataGrid
return false ;
return false ;
}
}
m_lastAddCount = - 1 ;
if ( oldStartIndex < newStartIndex )
RawItem [ ] rawItems = new RawItem [ count ] ;
List < RawItem > filteredRawItems = new List < RawItem > ( count ) ;
for ( int i = 0 ; i < count ; i + + )
{
{
RawItem rawItem = m_sourceItemList [ oldStartIndex + i ] ;
for ( int i = count - 1 ; i > = 0 ; i - - )
rawItems [ i ] = rawItem ;
// If our parent group is null, we are filtered out.
if ( rawItem . ParentGroup ! = null )
{
{
filteredRawItems . Add ( rawItem ) ;
var oldIndex = oldStartIndex + i ;
}
var newIndex = newStartIndex + i ;
}
int filteredItemCount = this . RemoveRawItemInFilteredList ( rawItems ) ;
Debug . Assert ( ( oldIndex > = 0 ) & & ( oldIndex < m_sourceItemList . Count ) ) ;
Debug . Assert ( ( newIndex > = 0 ) & & ( newIndex < m_sourceItemList . Count ) ) ;
Debug . Assert ( filteredItemCount = = filteredRawItems . Count ) ;
var rawItem = m_sourceItemList [ oldIndex ] ;
var wasFiltered = this . RemoveRawItemInFilteredList ( rawItem ) ;
m_sourceItemList . RemoveRange ( oldStart Index , count ) ;
m_sourceItemList . RemoveAt ( oldIndex ) ;
m_sourceItemList . InsertRange ( newStart Index , rawItems ) ;
m_sourceItemList . Insert ( newIndex , rawItem ) ;
int startIndex = Math . Min ( oldStartIndex , newStartIndex ) ;
for ( int j = oldIndex ; j < = newIndex ; j + + )
int endIndex = Math . Max ( oldStartIndex , newStartIndex ) + count ;
{
m_sourceItemList [ j ] . SetIndex ( j ) ;
}
for ( int i = startIndex ; i < endIndex ; i + + )
if ( wasFiltered )
{
{
m_sourceItemList [ i ] . SetIndex ( i ) ;
this . AddRawItemInFilteredList ( rawItem ) ;
this . EnsurePosition ( rawItem , rawItem . GetGlobalSortedIndex ( ) ) ;
}
}
}
}
else if ( oldStartIndex > newStartIndex )
{
for ( int i = 0 ; i < count ; i + + )
{
var oldIndex = oldStartIndex + i ;
var newIndex = newStartIndex + i ;
filteredItemCount = filteredRawItems . Count ;
Debug . Assert ( ( oldIndex > = 0 ) & & ( oldIndex < m_sourceItemList . Count ) ) ;
Debug . Assert ( ( newIndex > = 0 ) & & ( newIndex < m_sourceItemList . Count ) ) ;
if ( filteredItemCount > 0 )
var rawItem = m_sourceItemList [ oldIndex ] ;
{
var wasFiltered = this . RemoveRawItemInFilteredList ( rawItem ) ;
this . AddRawItemInFilteredList ( filteredRawItems , false ) ;
for ( int i = 0 ; i < filteredItemCount ; i + + )
m_sourceItemList . RemoveAt ( oldIndex ) ;
{
m_sourceItemList . Insert ( newIndex , rawItem ) ;
RawItem rawItem = filteredRawItems [ i ] ;
this . EnsurePosition ( rawItem , rawItem . GetGlobalSortedIndex ( ) ) ;
for ( int j = newIndex ; j < = oldIndex ; j + + )
{
m_sourceItemList [ j ] . SetIndex ( j ) ;
}
if ( wasFiltered )
{
this . AddRawItemInFilteredList ( rawItem ) ;
this . EnsurePosition ( rawItem , rawItem . GetGlobalSortedIndex ( ) ) ;
}
}
}
}
}
@ -1737,7 +1725,7 @@ namespace Xceed.Wpf.DataGrid
private bool ResetSourceItem ( object dataItem )
private bool ResetSourceItem ( object dataItem )
{
{
RawItem rawItem = null ;
var rawItem = default ( RawItem ) ;
//Verify if the item is in the same detail CollectionView as the previous item was found in.
//Verify if the item is in the same detail CollectionView as the previous item was found in.
if ( m_currentChildCollectionView ! = null )
if ( m_currentChildCollectionView ! = null )
@ -1760,23 +1748,22 @@ namespace Xceed.Wpf.DataGrid
//If the item was found, refresh it.
//If the item was found, refresh it.
if ( rawItem ! = null )
if ( rawItem ! = null )
{
{
int globalSortedIndex = rawItem . GetGlobalSortedIndex ( ) ;
this . EnsurePosition ( rawItem , rawItem . GetGlobalSortedIndex ( ) ) ;
this . EnsurePosition ( rawItem , globalSortedIndex ) ;
return true ;
return true ;
}
}
//If the item was not found, look for it in an expended detail.
//If the item was not found, look for it in an expended detail.
foreach ( DataGridContext detailContext in this . DataGridContext . GetChildContextsCore ( ) )
foreach ( var detailContext in this . DataGridContext . GetChildContextsCore ( ) )
{
{
DataGridCollectionView detailCollectionView = detailContext . Items as DataGridCollectionView ;
var detailCollectionView = detailContext . Items as DataGridCollectionView ;
if ( detailCollectionView ! = null )
if ( detailCollectionView = = null )
continue ;
if ( detailCollectionView . ResetSourceItem ( dataItem ) )
{
{
if ( detailCollectionView . ResetSourceItem ( dataItem ) )
//keep a reference to the detail CollectionView the item was found in, in case following items belong to the same detail.
{
m_currentChildCollectionView = detailCollectionView ;
//keep a reference to the detail CollectionView the item was found in, in case following items belong to the same detail.
return true ;
m_currentChildCollectionView = detailCollectionView ;
return true ;
}
}
}
}
}
@ -1791,38 +1778,34 @@ namespace Xceed.Wpf.DataGrid
}
}
}
}
private void AddRawItemInSourceList ( int startI ndex, IList < RawItem > rawItems )
private void AddRawItemInSourceList ( int i ndex, RawItem rawItem )
{
{
m_sourceItemList . InsertRange ( startIndex , rawItems ) ;
Debug . Assert ( ( index > = 0 ) & & ( index < = m_sourceItemList . Count ) ) ;
Debug . Assert ( rawItem ! = null ) ;
foreach ( RawItem rawItem in rawItems )
m_sourceItemList . Insert ( index , rawItem ) ;
{
this . AddRawItemDataItemMapping ( rawItem ) ;
}
int count = m_sourceItemList . Count ;
this . AddRawItemDataItemMapping ( rawItem ) ;
for ( int i = startIndex + rawItems . Count ; i < count ; i + + )
for ( var i = m_sourceItemList . Count - 1 ; i > index ; i - - )
{
{
m_sourceItemList [ i ] . SetIndex ( i ) ;
m_sourceItemList [ i ] . SetIndex ( i ) ;
}
}
}
}
private void AddRawItemInFilteredList ( IList < RawItem > rawItems , bool isLast )
private void AddRawItemInFilteredList ( RawItem rawItem )
{
{
Debug . Assert ( rawItem ! = null ) ;
// The function take for granted that all RawItem's index are sequential,
// The function take for granted that all RawItem's index are sequential,
// or if there is gap, the index contained in the gap are not already contained in the list.
// or if there is gap, the index contained in the gap are not already contained in the list.
if ( ( m_filteredItemList . Count = = 0 ) | | ( m_filteredItemList . Last ( ) . Index < rawItem . Index ) )
int index ;
if ( isLast )
{
{
index = m_filteredItemList . Count ;
m_filteredItemList . Add ( rawItem ) ;
}
}
else
else
{
{
index = m_filteredItemList . BinarySearch ( rawItems [ 0 ] , DataGridCollectionView . RawItemIndexComparer ) ;
var index = m_filteredItemList . BinarySearch ( rawItem , DataGridCollectionView . RawItemIndexComparer ) ;
Debug . Assert ( index < 0 ) ;
Debug . Assert ( index < 0 ) ;
if ( index < 0 )
if ( index < 0 )
@ -1830,35 +1813,25 @@ namespace Xceed.Wpf.DataGrid
index = ~ index ;
index = ~ index ;
}
}
Debug . Assert ( index < = m_filteredItemList . Count ) ;
m_filteredItemList . Insert ( index , rawItem ) ;
}
m_filteredItemList . InsertRange ( index , rawItems ) ;
}
private void AddRawItemInGroup ( IList < RawItem > rawItems )
{
int count = rawItems . Count ;
for ( int i = 0 ; i < count ; i + + )
{
this . AddRawItemInGroup ( rawItems [ i ] ) ;
}
}
}
}
private void AddRawItemInGroup ( RawItem rawItem )
private void AddRawItemInGroup ( RawItem rawItem )
{
{
Debug . Assert ( rawItem ! = null ) ;
using ( this . DeferCurrencyEvent ( ) )
using ( this . DeferCurrencyEvent ( ) )
{
{
DataGridCollectionViewGroup newGroup = this . GetRawItemNewGroup ( rawItem ) ;
var newGroup = this . GetRawItemNewGroup ( rawItem ) ;
int index = newGroup . BinarySearchRawItem ( rawItem , this . RawItemSortComparer ) ;
var index = newGroup . BinarySearchRawItem ( rawItem , this . RawItemSortComparer ) ;
if ( index < 0 )
if ( index < 0 )
{
{
index = ~ index ;
index = ~ index ;
}
}
int globalIndex = newGroup . GetFirstRawItemGlobalSortedIndex ( ) + index ;
var globalIndex = newGroup . GetFirstRawItemGlobalSortedIndex ( ) + index ;
this . AdjustCurrencyBeforeAdd ( globalIndex ) ;
this . AdjustCurrencyBeforeAdd ( globalIndex ) ;
newGroup . InsertRawItem ( index , rawItem ) ;
newGroup . InsertRawItem ( index , rawItem ) ;
@ -1869,89 +1842,74 @@ namespace Xceed.Wpf.DataGrid
this . OnCollectionChanged ( new NotifyCollectionChangedEventArgs ( NotifyCollectionChangedAction . Add , rawItem . DataItem , globalIndex ) ) ;
this . OnCollectionChanged ( new NotifyCollectionChangedEventArgs ( NotifyCollectionChangedAction . Add , rawItem . DataItem , globalIndex ) ) ;
}
}
}
private void RemoveRawItemInSourceList ( int startIndex , int count )
//When adding an item, make sure all stats for the specified group are recalculated even if UpdateChangedPropertyStatsOnly is set to true
{
if ( m_statFunctions . Count > 0 )
int endIndex = startIndex + count - 1 ;
for ( int i = startIndex ; i < = endIndex ; i + + )
{
{
this . RemoveRawItemDataItemMapping ( m_sourceItemList [ i ] ) ;
this . DeferredOperationManager . InvalidateGroupStats ( rawItem . ParentGroup , true ) ;
}
}
}
private void RemoveRawItemInSourceList ( int index )
{
Debug . Assert ( ( index > = 0 ) & & ( index < m_sourceItemList . Count ) ) ;
this . RemoveRawItemDataItemMapping ( m_sourceItemList [ index ] ) ;
m_sourceItemList . RemoveRange ( startIndex , count ) ;
m_sourceItemList . RemoveAt ( index ) ;
int totalCount = m_sourceItemList . Count ;
for ( int i = startIndex ; i < totalCount ; i + + )
for ( int i = m_sourceItemList . Count - 1 ; i > = index ; i - - )
{
{
m_sourceItemList [ i ] . SetIndex ( i ) ;
m_sourceItemList [ i ] . SetIndex ( i ) ;
}
}
}
}
private int RemoveRawItemInFilteredList ( IList < RawItem > rawItems )
private bool RemoveRawItemInFilteredList ( RawItem rawItem )
{
{
Debug . Assert ( rawItem ! = null ) ;
// The function take for granted that all RawItem's index are sequential,
// The function take for granted that all RawItem's index are sequential,
// There should not be any gap in the index sequence.
// There should not be any gap in the index sequence.
var index = m_filteredItemList . BinarySearch ( rawItem , DataGridCollectionView . RawItemIndexComparer ) ;
int index = m_filteredItemList . BinarySearch ( rawItems [ 0 ] , DataGridCollectionView . RawItemIndexComparer ) ;
if ( index < 0 )
if ( index < 0 )
{
return false ;
index = ~ index ;
}
if ( index > m_filteredItemList . Count )
return 0 ;
int lastRawItemIndex = rawItems [ rawItems . Count - 1 ] . Index ;
int count = m_filteredItemList . Count ;
int countToRemove = 0 ;
for ( int i = index ; i < count ; i + + )
Debug . Assert ( ( index > = 0 ) & & ( index < m_filteredItemList . Count ) ) ;
{
if ( m_filteredItemList [ i ] . Index < = lastRawItemIndex )
{
countToRemove + + ;
}
}
if ( countToRemove > 0 )
m_filteredItemList . RemoveAt ( index ) ;
{
m_filteredItemList . RemoveRange ( index , countToRemove ) ;
}
return countToRemov e;
return true ;
}
}
private void RemoveRawItemInGroup ( IList < RawItem > rawItems )
private void RemoveRawItemInGroup ( RawItem rawItem )
{
{
int count = rawItems . Count ;
Debug . Assert ( rawItem ! = null ) ;
for ( int i = 0 ; i < count ; i + + )
var parentGroup = rawItem . ParentGroup ;
if ( parentGroup = = null )
return ;
var globalSortedIndex = rawItem . GetGlobalSortedIndex ( ) ;
using ( this . DeferCurrencyEvent ( ) )
{
{
RawItem oldRawItem = rawItems [ i ] ;
this . AdjustCurrencyBeforeRemove ( globalSortedIndex ) ;
DataGridCollectionViewGroup parentGroup = oldRawItem . ParentGroup ;
parentGroup . RemoveRawItemAt ( rawItem . SortedIndex ) ;
if ( parentGroup ! = null )
unchecked
{
{
int globalSortedIndex = oldRawItem . GetGlobalSortedIndex ( ) ;
m_sortedItemVersion + + ;
}
using ( this . DeferCurrencyEvent ( ) )
}
{
this . AdjustCurrencyBeforeRemove ( globalSortedIndex ) ;
parentGroup . RemoveRawItemAt ( oldRawItem . SortedIndex ) ;
unchecked
// In the case of a remove, the CollectionChanged must be after the CurrentChanged since when the DataGridCollectionView is used with a Selector having the
{
// IsSynchronizedWithCurrent set, the Selector will set the current position to -1 if the selected item is removed.
m_sortedItemVersion + + ;
this . OnCollectionChanged ( new NotifyCollectionChangedEventArgs ( NotifyCollectionChangedAction . Remove , rawItem . DataItem , globalSortedIndex ) ) ;
}
}
// In the case of a remove, the CollectionChanged must be after the CurrentChanged since when the DataGridCollectionView is used with a Selector having the
//When removing an item, make sure all stats for the specified group are recalculated even if UpdateChangedPropertyStatsOnly is set to true
// IsSynchronizedWithCurrent set, the Selector will set the current position to -1 if the selected item is removed.
if ( m_statFunctions . Count > 0 )
this . OnCollectionChanged ( new NotifyCollectionChangedEventArgs ( NotifyCollectionChangedAction . Remove , oldRawItem . DataItem , globalSortedIndex ) ) ;
{
}
this . DeferredOperationManager . InvalidateGroupStats ( parentGroup , true ) ;
}
}
}
}