Export (0) Print
Expand All

CollectionView.MoveCurrentTo Method

Set the specified item to be the CurrentItem in the view.

Namespace: System.Windows.Data
Assembly: PresentationFramework (in presentationframework.dll)

public virtual bool MoveCurrentTo (
	Object item
)
public boolean MoveCurrentTo (
	Object item
)
public function MoveCurrentTo (
	item : Object
) : boolean
You cannot use methods in XAML.

Parameters

item

Return Value

true if the resulting CurrentItem is within the view; otherwise, false.

If the specified item is not found, the method returns false and the CurrentItem is at the position before the beginning of the collection in the view.

See CurrentItem for more information about the current item of a view.

The following example demonstrates the use of this method:

// 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);
}

For the complete example, see Showing System Colors Using Data Services Sample.

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0

Community Additions

ADD
Show:
© 2014 Microsoft