-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #815 from telerik/new-kb-changing-edit-mode-behavi…
…or-maui-raddatagrid-df4786f67e9747ea9a43d73ec3d0b9ec Added new kb article changing-edit-mode-behavior-maui-raddatagrid
- Loading branch information
Showing
1 changed file
with
58 additions
and
0 deletions.
There are no files selected for viewing
58 changes: 58 additions & 0 deletions
58
knowledge-base/changing-edit-mode-behavior-maui-raddatagrid.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
--- | ||
title: Changing Edit Mode Behavior in DataGrid for MAUI | ||
description: Learn how to modify the edit mode behavior in RadDataGrid for MAUI to enter edit mode with a single click instead of a double-click. | ||
type: how-to | ||
page_title: Changing Edit Mode Behavior in RadDataGrid for MAUI | ||
slug: changing-edit-mode-behavior-maui-raddatagrid | ||
tags: maui, raddatagrid, edit mode, cell tap, cell double tap | ||
res_type: kb | ||
--- | ||
## Environment | ||
| Property | Value | | ||
|---|---| | ||
| Product | DataGrid for MAUI | | ||
| Version | 6.7.0 | | ||
|
||
## Description | ||
I want to modify the behavior of the RadDataGrid in my .NET Maui application so that it enters edit mode with a single click instead of requiring a double-click. | ||
|
||
## Solution | ||
To achieve this, you can use a custom `CellTap` command called `CellTapUserCommand`. Here's an example of how to implement it: | ||
|
||
```csharp | ||
public class CellTapUserCommand : DataGridCommand | ||
{ | ||
public CellTapUserCommand() | ||
{ | ||
Id = DataGridCommandId.CellTap; | ||
} | ||
|
||
public override bool CanExecute(object parameter) | ||
{ | ||
return true; | ||
} | ||
|
||
public override void Execute(object parameter) | ||
{ | ||
if (parameter is not DataGridCellInfo cellInfo) | ||
{ | ||
return; | ||
} | ||
|
||
this.Owner.CommandService.ExecuteDefaultCommand(DataGridCommandId.CellDoubleTap, parameter); | ||
} | ||
} | ||
``` | ||
|
||
To apply the `CellTapUserCommand` to your RadDataGrid, add it to the `Commands` collection: | ||
|
||
```csharp | ||
this.dataGrid.Commands.Add(new CellTapUserCommand()); | ||
``` | ||
|
||
By utilizing this custom command, you can now enter edit mode with a single click on a cell in the RadDataGrid. | ||
|
||
## See Also | ||
|
||
- [DataGrid for .NET MAUI Documentation](https://docs.telerik.com/devtools/maui/controls/datagrid/overview) | ||
- [DataGrid Commands](https://docs.telerik.com/devtools/maui/controls/datagrid/commands/overview) |