/// <summary>
/// Handle keys related to scrolling.
/// </summary>
/// <param name="key">The key to handle.</param>
/// <returns>A value indicating whether the key was handled.</returns>
private bool HandleScrollKeys(Key key)
{
ScrollViewer scrollHost = ItemsControlHelper.ScrollHost;
if (scrollHost != null)
{
switch (key)
{
case Key.PageUp:
// Move horizontally if we've run out of room vertically
if (!NumericExtensions.IsGreaterThan(scrollHost.ExtentHeight, scrollHost.ViewportHeight))
{
scrollHost.PageLeft();
}
else
{
scrollHost.PageUp();
}
return(true);
case Key.PageDown:
// Move horizontally if we've run out of room vertically
if (!NumericExtensions.IsGreaterThan(scrollHost.ExtentHeight, scrollHost.ViewportHeight))
{
scrollHost.PageRight();
}
else
{
scrollHost.PageDown();
}
return(true);
case Key.Home:
scrollHost.ScrollToTop();
return(true);
case Key.End:
scrollHost.ScrollToBottom();
return(true);
case Key.Left:
scrollHost.LineLeft();
return(true);
case Key.Right:
scrollHost.LineRight();
return(true);
case Key.Up:
scrollHost.LineUp();
return(true);
case Key.Down:
scrollHost.LineDown();
return(true);
}
}
return(false);
}