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として設定する項目。

返品

結果の がビュー内にある場合は a0/& 。それ以外の場合は。

実装

次の例では、このメソッドの使用方法を示します。

// 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」を参照してください。

適用対象

こちらもご覧ください