CollectionView.MoveCurrentTo(Object) 메서드

정의

지정한 항목을 뷰의 CurrentItem으로 설정합니다.

public:
 virtual bool MoveCurrentTo(System::Object ^ item);
public virtual bool MoveCurrentTo (object item);
abstract member MoveCurrentTo : obj -> bool
override this.MoveCurrentTo : obj -> bool
Public Overridable Function MoveCurrentTo (item As Object) As Boolean

매개 변수

item
Object

CurrentItem으로 설정할 항목입니다.

반환

결과 CurrentItem이 뷰 내에 있으면 true이고, 그렇지 않으면 false입니다.

구현

예제

다음 예제에서는이 메서드를 사용 하는 방법을 보여 줍니다.

// Event handler for the NewColor button
void  OnNewColorClicked(object sender, RoutedEventArgs args)
{
  Button button = (Button)sender;
  ColorItemList colorList = (ColorItemList)button.DataContext;
  CollectionView cv = (CollectionView)CollectionViewSource.GetDefaultView((IEnumerable)colorList);

  // add a new color based on the current one, then select the new one
  ColorItem newItem = new ColorItem((ColorItem)cv.CurrentItem);
  colorList.Add(newItem);
  cv.MoveCurrentTo(newItem);
}
' Event handler for the NewColor button
Private Sub OnNewColorClicked(ByVal sender As Object, ByVal args As RoutedEventArgs)
  Dim button As Button = CType(sender, Button)
  Dim colorList As ColorItemList = CType(button.DataContext, ColorItemList)
  Dim cv As CollectionView = CType(CollectionViewSource.GetDefaultView(CType(colorList, IEnumerable)), CollectionView)

  ' add a new color based on the current one, then select the new one
  Dim newItem As New ColorItem(CType(cv.CurrentItem, ColorItem))
  colorList.Add(newItem)
  cv.MoveCurrentTo(newItem)
End Sub

설명

지정한 항목을 찾을 수 없으면 메서드가 를 반환 false 하고 CurrentItem 는 뷰에서 컬렉션의 시작 앞에 배치됩니다.

컬렉션 뷰는 현재 레코드 포인터의 개념을 지원합니다. 컬렉션 뷰에서 개체를 탐색할 때 컬렉션의 특정 위치에 있는 개체를 검색할 수 있는 레코드 포인터를 이동합니다. 자세한 내용은 데이터 바인딩 개요의 "컬렉션에 바인딩"을 참조하세요.

보기의 현재 항목에 대한 자세한 내용은 를 참조하세요 CurrentItem.

적용 대상

추가 정보