@@ -596,7 +596,7 @@ public DependencyObject ContainerFromItem(object item)
596
596
int index ;
597
597
598
598
DoLinearSearch (
599
- delegate ( object o , DependencyObject d ) { return ItemsControl . EqualsEx ( o , item ) ; } ,
599
+ static ( state , o , d ) => ItemsControl . EqualsEx ( o , state ) , item ,
600
600
out dummy , out container , out index , false ) ;
601
601
602
602
return container ;
@@ -627,18 +627,17 @@ public int IndexFromContainer(DependencyObject container, bool returnLocalIndex)
627
627
DependencyObject dummy ;
628
628
629
629
DoLinearSearch (
630
- delegate ( object o , DependencyObject d ) { return ( d == container ) ; } ,
630
+ static ( state , o , d ) => d == state , container ,
631
631
out item , out dummy , out index , returnLocalIndex ) ;
632
632
633
633
return index ;
634
634
}
635
635
636
636
// expose DoLinearSearch to internal code
637
- internal bool FindItem ( Func < object , DependencyObject , bool > match ,
637
+ internal bool FindItem < TState > ( Func < TState , object , DependencyObject , bool > match , TState matchState ,
638
638
out DependencyObject container , out int itemIndex )
639
639
{
640
- object item ;
641
- return DoLinearSearch ( match , out item , out container , out itemIndex , false ) ;
640
+ return DoLinearSearch ( match , matchState , out _ , out container , out itemIndex , false ) ;
642
641
}
643
642
644
643
/// <summary>
@@ -685,7 +684,7 @@ internal bool FindItem(Func<object, DependencyObject, bool> match,
685
684
/// <returns>
686
685
/// true if found, false otherwise.
687
686
/// </returns>
688
- private bool DoLinearSearch ( Func < object , DependencyObject , bool > match ,
687
+ private bool DoLinearSearch < TState > ( Func < TState , object , DependencyObject , bool > match , TState matchState ,
689
688
out object item , out DependencyObject container , out int itemIndex ,
690
689
bool returnLocalIndex )
691
690
{
@@ -746,7 +745,7 @@ private bool DoLinearSearch(Func<object, DependencyObject, bool> match,
746
745
for ( ; offset < endOffset ; ++ offset )
747
746
{
748
747
CollectionViewGroup group ;
749
- bool found = match ( rib . ItemAt ( offset ) , rib . ContainerAt ( offset ) ) ;
748
+ bool found = match ( matchState , rib . ItemAt ( offset ) , rib . ContainerAt ( offset ) ) ;
750
749
751
750
if ( found )
752
751
{
@@ -758,7 +757,7 @@ private bool DoLinearSearch(Func<object, DependencyObject, bool> match,
758
757
// found a group; see if the group contains the item
759
758
GroupItem groupItem = ( GroupItem ) rib . ContainerAt ( offset ) ;
760
759
int indexInGroup ;
761
- found = groupItem . Generator . DoLinearSearch ( match , out item , out container , out indexInGroup , false ) ;
760
+ found = groupItem . Generator . DoLinearSearch ( match , matchState , out item , out container , out indexInGroup , false ) ;
762
761
if ( found )
763
762
{
764
763
itemIndex = indexInGroup ;
0 commit comments