public static ScrollToCenterOfView ( this itemsControl, object item ) : void | ||
itemsControl | this | |
item | object | |
return | void |
public static void ScrollToCenterOfView(this ItemsControl itemsControl, object item)
{
// Scroll immediately if possible
if (!itemsControl.TryScrollToCenterOfView(item))
{
// Otherwise wait until everything is loaded, then scroll
if (itemsControl is ListBox) ((ListBox)itemsControl).ScrollIntoView(item);
itemsControl.Dispatcher.BeginInvoke(DispatcherPriority.Loaded, new System.Action(() =>
{
itemsControl.TryScrollToCenterOfView(item);
}));
}
}