This question is locked. New answers and comments are not allowed.
Hello,
I have a grid with a custom edit command and a template column with a button. I'm attempting to invoke the custom edit command from clicking the button, but the parameter object passed to the Execute method is null. This object is instantiated when using the built-in edit functionality through double-clicking on the row or pressing F2 on the keyboard, but not when the edit button is clicked.
How can I pass the EditContext parameter to my custom command from this button? Please note that I am working with the MVVM Light toolkit.
Thanks!
Geoff
I have a grid with a custom edit command and a template column with a button. I'm attempting to invoke the custom edit command from clicking the button, but the parameter object passed to the Execute method is null. This object is instantiated when using the built-in edit functionality through double-clicking on the row or pressing F2 on the keyboard, but not when the edit button is clicked.
How can I pass the EditContext parameter to my custom command from this button? Please note that I am working with the MVVM Light toolkit.
<RadGrid:RadDataGrid Name="rdgPlay" Grid.Row="0" ItemsSource="{Binding Plays}" DataBindingComplete="rdgPlay_DataBindingComplete" UserSortMode="None" UserFilterMode="Disabled" UserGroupMode="Disabled" UserEditMode="Inline" SelectionMode="None"> <RadGrid:RadDataGrid.Columns> <RadGrid:DataGridTemplateColumn CanUserEdit="False"> <RadGrid:DataGridTemplateColumn.CellContentTemplate> <DataTemplate> <StackPanel> <Button Content="Edit"> <Button.Command> <CustomCommands:CustomBeginEditCommand /> </Button.Command> </Button> </StackPanel> </DataTemplate> </RadGrid:DataGridTemplateColumn.CellContentTemplate> </RadGrid:DataGridTemplateColumn> </RadGrid:RadDataGrid.Columns> <RadGrid:RadDataGrid.Commands> <CustomCommands:CustomBeginEditCommand /> </RadGrid:RadDataGrid.Commands></RadGrid:RadDataGrid>public class CustomBeginEditCommand : DataGridCommand{ public CustomBeginEditCommand() { // Set Id so that this command can be properly associated with the desired action/event Id = CommandId.BeginEdit; } public override bool CanExecute(object parameter) { return true; } public override void Execute(object parameter) { base.Execute(parameter); var context = parameter as EditContext; // parameter is sometimes null
// Executes the default implementation of this command this.Owner.CommandService.ExecuteDefaultCommand(Id, context); }}Thanks!
Geoff