using System.Collections.Generic;
using System.Linq;
using Telerik.Windows.Controls.GridView;
using System.Windows.Input;

namespace FocusOnTabToTextBox
{
	class CustomKeyboardCommandProvider : DefaultKeyboardCommandProvider  
	{
		GridViewDataControl parentGrid;
		public CustomKeyboardCommandProvider(GridViewDataControl grid)
			: base(grid)
		{
			this.parentGrid = grid;
		}

		public override IEnumerable<ICommand> ProvideCommandsForKey(Key key)
		{
			List<ICommand> commandsToExecute = base.ProvideCommandsForKey(key).ToList();

			if (key == Key.Tab && this.parentGrid.CurrentColumn == this.parentGrid.Columns[this.parentGrid.Columns.Count - 1])
			{				
				commandsToExecute.Clear();
			}			

			return commandsToExecute;
		}
	}
}
