This is a migrated thread and some comments may be shown as answers.

ApplicationCommands.Delete context menu is disabled

3 Answers 298 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Karl B
Top achievements
Rank 1
Karl B asked on 20 Jul 2020, 04:56 PM

In the sample below, copy and paste will operate on the row as expected but delete is disabled. I'm expecting delete to allow me to delete the row (as if I pressed the delete key on the keyboard).

 

<telerik:RadGridView x:Name="RadGridView" >
    <telerik:RadGridView.ContextMenu>
        <ContextMenu >
            <MenuItem Command="ApplicationCommands.Copy"></MenuItem>
            <MenuItem Command="ApplicationCommands.Paste"></MenuItem>
            <MenuItem Command="ApplicationCommands.Delete"></MenuItem>
        </ContextMenu>
    </telerik:RadGridView.ContextMenu>
</telerik:RadGridView>

 

public GridMenuTestWindow ()
        {
        InitializeComponent ();
 
        ObservableCollection<MyData> dataList = new ObservableCollection<MyData> ();
 
        for (int i = 0; i < 4; i++)
            {
            dataList.Add (new MyData () {Name = "Name" + i});
            }
        this.RadGridView.ItemsSource = dataList;      
        }  
 
public class MyData
    {
    public String Name { get; set; }
    }

3 Answers, 1 is accepted

Sort by
0
Dinko | Tech Support Engineer
Telerik team
answered on 21 Jul 2020, 09:21 AM

Hello Karl,

Thank you for the provided code snippets.

You need to use RadGridViewCommands so that the Delete command to work. In your case, the first code snippet should look like the one below.

<telerik:RadGridView x:Name="RadGridView" >
    <telerik:RadGridView.ContextMenu>
        <ContextMenu >
            <MenuItem Command="telerik:RadGridViewCommands.Copy"></MenuItem>
            <MenuItem Command="telerik:RadGridViewCommands.Paste"></MenuItem>
            <MenuItem Command="telerik:RadGridViewCommands.Delete"></MenuItem>
        </ContextMenu>
    </telerik:RadGridView.ContextMenu>
</telerik:RadGridView>

In addition, you can check the following examples in our GitHub repository, which I think could get in handy for your case.

Regards,
Dinko
Progress Telerik

0
Karl B
Top achievements
Rank 1
answered on 21 Jul 2020, 02:59 PM

[quote]You need to use RadGridViewCommands so that the Delete command to work. In your case, the first code snippet should look like the one below.[/quote]

That worked, thank you. Is there advantage to using RadGridViewCommands Copy/Paste vs the ApplicationCommands version? They both appear to be doing the same thing but the ApplicationCommands menu give a nice hotkey reminder.

0
Dinko | Tech Support Engineer
Telerik team
answered on 24 Jul 2020, 08:12 AM

Hi Karl,

The RadGridViewCommands are designed to work with RadGridView control. Nevertheless that some of the ApplicationCommands works on the controls it is recommended to use RadGridViewCommands.

Regards,
Dinko
Progress Telerik

Tags
GridView
Asked by
Karl B
Top achievements
Rank 1
Answers by
Dinko | Tech Support Engineer
Telerik team
Karl B
Top achievements
Rank 1
Share this question
or