You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
jellyfin/MediaBrowser.UI.Controls/ExtendedScrollViewer.cs

42 lines
1.2 KiB

using System.Windows.Controls;
using System.Windows.Input;
namespace MediaBrowser.UI.Controls
{
/// <summary>
/// This subclass solves the problem of ScrollViewers eating KeyDown for all arrow keys
/// </summary>
public class ExtendedScrollViewer : ScrollViewer
{
protected override void OnKeyDown(KeyEventArgs e)
{
if (e.Handled || e.OriginalSource == this)
{
base.OnKeyDown(e);
return;
}
// Don't eat left/right if horizontal scrolling is disabled
if (e.Key == Key.Left || e.Key == Key.Right)
{
if (HorizontalScrollBarVisibility == ScrollBarVisibility.Disabled)
{
return;
}
}
// Don't eat up/down if vertical scrolling is disabled
if (e.Key == Key.Up || e.Key == Key.Down)
{
if (VerticalScrollBarVisibility == ScrollBarVisibility.Disabled)
{
return;
}
}
// Let the base class do it's thing
base.OnKeyDown(e);
}
}
}