Hi,
I have taken a look at the CustomKeyboardCommandProvider, here is mine:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Input;
using Telerik.Windows.Controls;
using Telerik.Windows.Controls.GridView;
namespace DyeingControl
{
class CustomKeyboardCommandProvider : DefaultKeyboardCommandProvider
{
private GridViewDataControl parentGrid;
private DefaultKeyboardCommandProvider defaultKeyboardProvider;
private CustomKeyboardCommandProvider customKeyboardProvider;
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.Enter)
{
commandsToExecute.Clear();
commandsToExecute.Add(RadGridViewCommands.SelectCurrentItem);
}
return commandsToExecute;
}
}
}
And here I set it to the RadGridView:
RadGridView gvMachineType =
null
;
private
void
cbMachineType_DropDownOpened(
object
sender, EventArgs e)
{
var comboBox = sender
as
RadComboBox;
if
(comboBox !=
null
)
{
var popup = comboBox.ChildrenOfType<Popup>().FirstOrDefault();
if
(popup !=
null
)
{
var popUpContent = popup.Child
as
FrameworkElement;
if
(popUpContent !=
null
)
{
gvMachineType = popUpContent.ChildrenOfType<RadGridView>().FirstOrDefault();
if
(gvMachineType !=
null
)
{
gvMachineType.KeyboardCommandProvider =
new CustomKeyboardCommandProvider(gvMachineType);
Dispatcher.BeginInvoke(
new
Action(() =>
{
gvMachineType.Focus();
}));
}
}
}
}
}
Is this ok? Or should I do it in another way? When I debug it, the comipler runs through the CustomKeyboardCommandProvider Code and all is ok...but the behavior is still the same...