Hi,
i'm trying to use KeyboardCommandProvider, with binding in a MVVM scenario for managing the Enter key(i don't want to move down). I've read this post, https://docs.telerik.com/devtools/wpf/controls/radgridview/commands/keyboardcommandprovider and i try to implement my CustomKeyboardCommandProvider without success; i've a usercontrol with insede a GridView but i've an error message: "The type CustomKeyboardCommandProvider does not include any accessibile constructor". How can i solve it in my scenario?
This is my code:
XAML:
<UserControl.Resources>
<Conditional:CustomKeyboardCommandProvider x:Key="MyKeyboardCommand" />
</UserControl.Resources>
<telerik:RadGridView Grid.Column="0" Grid.Row="1" Name="MyRadGridArtworks"
ItemsSource="{Binding GridViewList, Mode=TwoWay}"
SelectedItem="{Binding GridViewRowSelected, Mode=TwoWay}"
EnableColumnVirtualization="False"
ValidatesOnDataErrors="None"
ShowColumnSortIndexes="False"
AutoGenerateColumns="False"
telerikControls:StyleManager.Theme="Office2013"
ColumnWidth="auto"
CanUserFreezeColumns="True"
LeftFrozenColumnCount="3"
ShowColumnFooters="True"
KeyboardCommandProvider="{StaticResource MyKeyboardCommand}"
IsLocalizationLanguageRespected="False"
RowIndicatorVisibility="Collapsed">
</telerik:RadGridView>
C# --> CustomKeyboardCommandProvider
public class CustomKeyboardCommandProvider : DefaultKeyboardCommandProvider
{
private GridViewDataControl dataControl;
public CustomKeyboardCommandProvider(GridViewDataControl dataControl ) : base(dataControl)
{
this.dataControl = dataControl;
}
public override IEnumerable<System.Windows.Input.ICommand> ProvideCommandsForKey(System.Windows.Input.Key key)
{
if (key != System.Windows.Input.Key.Return)
// use default behavior for all keys except Return
return base.ProvideCommandsForKey(key);
List<ICommand> commandsToExecute = new List<ICommand>();
if (this.dataControl.CurrentCell == null)
return commandsToExecute;
if (this.dataControl.CurrentCell.IsInEditMode)
{
commandsToExecute.Add(RadGridViewCommands.CommitEdit);
}
else
{
commandsToExecute.Add(RadGridViewCommands.ActivateRow);
}
return commandsToExecute;
}
}